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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -