Hi,
I'm trying to take a date, add a day to it, and then convert it to a string. The date's format starts out like: '10/1/2009', and should end like: '2009-10-1'.
I can do that part, but then I can't convert it to a date format and add a day. Here's what I have so far:
#!/usr/bin/env python
import time
import datetime
epdate = episode_content[entry_number][index2+13:index3].replace('/', '-') #reformat so that the slashes are replaced
epdate = epdate.split('-') #split the string into three
epdate = epdate[2] + '-' + epdate[0] + '-' + epdate[1] #reorder the date to the correct format
epdate = epdate.replace(' ', '')#make sure there are no whitespaces
episode_date.append (epdate) #add it to my dictionary
epdate = time.strptime(epdate, '%Y-%m-%d') #convert epdate to time type
epdatestart = datetime.datetime(*time.strptime(epdate, '%Y-%m-%d')[:6]) #save as start date in datetype form
epdateend = datetime.datetime(*time.strptime(epdate, '%Y-%m-%d')[:6]) + datetime.timedelta(days=1) #save as end date in datetype form
#epdate2 = epdate + datetime.timedelta(days=1)
print str(epdatestart)
print str(epdateend)
At the moment, the error I get is caused by the 'strptime':
TypeError: expected string of buffer
Any help is appreciated
Thanks