0 votes
1 view
in Python by (45.1k 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.8k points)
0 votes
1 answer
asked Jul 30, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...