replace hours in a datetime type python

I have a datetime type mydate in %Y-%m-%dT%H:%M:%S format.
I want to replace the hours
I did this using mydate.replace() method
Now I want to comapre it with another specific date -> myNEWdate whose format is
%Y-%m-%d %H:%M:%S

    newdate = mydate.replace(hour = islot)
    print newdate
    appointmentDict[mydate]['time_start'] = datetime.strptime(str(newdate),"%Y/%m/%d %H:%M:%S")

The date is printed as 2015-06-26 08:00:00
and I get the error
ValueError: time data ‘2015-06-26 08:00:00’ does not match format ‘%Y/%m/%d %H:%M:%S’

What should I do to resolve this

Source: python

Leave a Reply