datetime - How to perform arithmetic operation on a date in Python? -
i have date column in csv file date
having dates in format 04/21/2013
, have 1 more column next_day
. in next_day
column want populate date comes after date mentioned in date column. eg. if date column has 04/21/2013
date want 04/22/2013
in next_day column.
we can use +1
in excel don't know how perform in python.
please me in resolving this.
using datetime.timedelta
>>> import datetime >>> s = '04/21/2013' >>> d = datetime.datetime.strptime(s, '%m/%d/%y') + datetime.timedelta(days=1) >>> print d.strftime('%m/%d/%y') 04/22/2013
Comments
Post a Comment