from datetime import date, timedelta
yesterday = date.today() - timedelta(1)
print yesterday #date object
print yesterday.strftime('%Y-%m-%d') #string object in form of yyyy-mm-dd
print yesterday.strftime('%y-%m-%d') #string object in form of yy-mm-dd
Ref: http://docs.python.org/2/library/datetime.html
No comments:
Post a Comment