Greetings,
I have this date string that is given to me from somelses code 20080326 and I want to convert it to be MMddYYYY and I get this error:
Caught Exception:
ValueError:time data did not match format: data=20080326 fmt=%m%d%Y
File "/home/gateway/scripts/python/py-allston.egg/main_template.py", line 91, in decorated_main
File "db.py", line 24, in main
print time.strptime(timestamp,"%m%d%Y")
File "/usr/lib64/python2.4/_strptime.py", line 293, in strptime
raise ValueError("time data did not match format: data=%s fmt=%s" %


Here is the code

timestamp= "20080326"
 print time.strptime(timestamp,"%m%d%Y")

I thought I was doing it right according to the googling i did but im afraid i misunderstood something. Thank you for the help on this matter.

Try print time.strptime(timestamp,"%Y%m%d") since the year comes first in your example.

that worked wonderfully thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.