Raven Smith
Raven Smith

Reputation: 127

Subtract 'n' weeks from current date python

Subtracting 'n' days from current date could be done using:

from datetime import datetime, timedelta
datetime.today() - timedelta(days=42)

Similarly, Is there a way to subtract 'n' weeks from current date in python

Upvotes: 2

Views: 5347

Answers (2)

Shubhm
Shubhm

Reputation: 17

Unnecessary, but you can also do:

datetime.today() - timedelta(days=n*7)

Upvotes: -1

Abhilash Awasthi
Abhilash Awasthi

Reputation: 797

This works..

datetime.today() - timedelta(weeks=42)

Upvotes: 8

Related Questions