Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the date of 7 days ago from current date in python [closed]

I'm trying to get the date that was 7 days ago starting from current date in python. Can anyone help me?

like image 507
John Adam Avatar asked Dec 13 '13 18:12

John Adam


People also ask

How do you add or subtract days from a date in python?

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.


1 Answers

import datetime as DT today = DT.date.today() week_ago = today - DT.timedelta(days=7) 
like image 74
unutbu Avatar answered Oct 15 '22 07:10

unutbu