[Python] Return datetime object of previous month

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    If only timedelta had a month argument in it's constructor. So what's the simplest way to do this?

    EDIT: I wasn't thinking too hard about this as was pointed out below. Really what I wanted was any day in the last month because eventually I'm going to grab the year and month only. So given a datetime object, what's the simplest way to return any datetime object that falls in the previous month?

    Continue reading...

Compartilhe esta Página