Home > Enterprise >  Yesterday date at the start of new mounth(Python)
Yesterday date at the start of new mounth(Python)

Time:09-22

I am just learning to program and I apologize for such a stupid question.

I need to find yesterday date, i use for it

import datetime


yesterday = datetime.date.today() - datetime.timedelta(days=1)
print(yesterday)

Output:

2021-09-18

And I asked myself this question:

Will it yesterday equal to "2021-08-31" if datetime.date.today() == "2021-09-01"

Or yesterday will be equal to "2021-09-00"

CodePudding user response:

That'll be equal to 2021-08-31.

  • Related