I'm trying to get the date that was 7 days ago starting from current date in python. Can anyone help me?
For adding or subtracting Date, we use something called timedelta() function which can be found under the DateTime class. It is used to manipulate Date, and we can perform arithmetic operations on dates like adding or subtracting.
import datetime as DT today = DT.date.today() week_ago = today - DT.timedelta(days=7)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With