date -d "-1 day" +%d%m will give me the yesterdays date.
date -d "-1 month" +%d%m will give me date one month previous.
Here is what you do in python for the same.
>>> import datetime
>>> today = datetime.date.today()
>>> today
datetime.date(2008, 3, 20)
>>> yesterday = today - datetime.timedelta(1)
>>> yesterday
datetime.date(2008, 3, 19)
>>> monthbefore = today - datetime.timedelta(31)
>>> monthbefore
datetime.date(2008, 2, 18)
>>>
3 comments:
Thanks a lot!!
Thanks this helped me
Sweet, thanks!
Post a Comment