By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

trouble with time --again

P: n/a
Hey there,
could someone show me where i am going wrong here?
date1 = '2005-01-01 8:20:00'
date1 = strptime('%Y-%m-%d %H:%M:%S',date1)


raise ValueError("time data did not match format: data=%s fmt=%s" %
ValueError: time data did not match format: data=%Y-%m-%d%H:%M:%S
fmt=2005-01-01 8:20:00

i have looked over the strptime and strftime over and over, dont get
where i am missing it here.

thanks

Aug 30 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 30 Aug 2005 10:42:41 -0700, ne*****@xit.net <ne*****@xit.net> wrote:
Hey there,
could someone show me where i am going wrong here?
date1 = '2005-01-01 8:20:00'
date1 = strptime('%Y-%m-%d %H:%M:%S',date1)
raise ValueError("time data did not match format: data=%s fmt=%s" %
ValueError: time data did not match format: data=%Y-%m-%d%H:%M:%S
fmt=2005-01-01 8:20:00


Try:
date1 = strptime(date1, '%Y-%m-%d %H:%M:%S')


I think you have the data and format strings swapped.

--
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
Aug 30 '05 #2

P: n/a
OH my god.
youre right.
i feel like a complete idiot.
thanks

Aug 30 '05 #3

P: n/a
On 30 Aug 2005 10:54:29 -0700, ne*****@xit.net <ne*****@xit.net> wrote:

i feel like a complete idiot.


Now don't go and do that. Mistakes happen.

--
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
Aug 30 '05 #4

P: n/a
he he. yep, just spent a lot of time on this one.
life moves on.
cheers!
sk

Aug 30 '05 #5

P: n/a
Hi !
Try :

import datetime
date1 = datetime.datetime(2005,01,01,8,20,0)
print date1.strftime('%Y-%m-%d %H:%M:%S')

@-salutations

Michel Claveau
Aug 31 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.