Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (45.3k points)

Today =

today = datetime.datetime.now().strftime("%Y%m%d")

90days ago

DD = datetime.timedelta(days=-90)

How do I get today - DD, or 90days ago?

1 Answer

0 votes
by (16.8k points)

You should be able to subtract time deltas from datetime objects.

today = datetime.datetime.now()

DD = datetime.timedelta(days=90)

earlier = today - DD

earlier_str = earlier.strftime("%Y%m%d")

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 17, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 30, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...