Connecting Tech Pros Worldwide Forums | Help | Site Map

trouble with time --again

nephish@xit.net
Guest
 
Posts: n/a
#1: Aug 30 '05
Hey there,
could someone show me where i am going wrong here?
[color=blue][color=green][color=darkred]
>>> date1 = '2005-01-01 8:20:00'
>>> date1 = strptime('%Y-%m-%d %H:%M:%S',date1)[/color][/color][/color]

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

Kristian Zoerhoff
Guest
 
Posts: n/a
#2: Aug 30 '05

re: trouble with time --again


On 30 Aug 2005 10:42:41 -0700, nephish@xit.net <nephish@xit.net> wrote:[color=blue]
> Hey there,
> could someone show me where i am going wrong here?
> [color=green][color=darkred]
> >>> date1 = '2005-01-01 8:20:00'
> >>> date1 = strptime('%Y-%m-%d %H:%M:%S',date1)[/color][/color]
>
> 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[/color]

Try:
[color=blue][color=green][color=darkred]
>>> date1 = strptime(date1, '%Y-%m-%d %H:%M:%S')[/color][/color][/color]

I think you have the data and format strings swapped.

--
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
nephish@xit.net
Guest
 
Posts: n/a
#3: Aug 30 '05

re: trouble with time --again


OH my god.
youre right.
i feel like a complete idiot.
thanks

Kristian Zoerhoff
Guest
 
Posts: n/a
#4: Aug 30 '05

re: trouble with time --again


On 30 Aug 2005 10:54:29 -0700, nephish@xit.net <nephish@xit.net> wrote:[color=blue]
>
> i feel like a complete idiot.[/color]

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

--
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
nephish@xit.net
Guest
 
Posts: n/a
#5: Aug 30 '05

re: trouble with time --again


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

Do Re Mi chel La Si Do
Guest
 
Posts: n/a
#6: Aug 31 '05

re: trouble with time --again


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


Closed Thread