How to get the date N days ago in Python

05:47:00 , 0 Comments

This a simple process on how to add day ahead of today in python
 
 
from datetime import datetime, timedelta

N = 2

date_N_days_ago = datetime.now() - timedelta(days=N)

print datetime.now()
print date_N_days_ago
Results:
2010-10-16 00:06:06.000201
2010-10-14 00:06:06.000107

0 comments :