datetime string conversion error

Jordan Apgar twistedphrame at gmail.com
Tue Mar 16 15:11:54 EDT 2010


On Mar 16, 3:07 pm, Christian Heimes <li... at cheimes.de> wrote:
> Jordan Apgar wrote:
> > Hey all,
> > I'm trying to convert a string to a date time object and all my fields
> > convert except for month which seems to default to january.
>
> > here's what I'm doing:
> > date = "2010-03-16 14:46:38.409137"
> >  olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f")
>
> > print date
> > print olddate
>
> > I get:
> > 2010-03-16 14:46:38.409137
> > 2010-01-16 14:46:38.409137
>
> > notice the 01 in the second date from what I could tell everything is
> > formatted correctly.
>
> %j is documtend as "Day of the year as a decimal number [001,366].". Did
> you mean %d instead?
>
> Christian

That fixed it, thank you




More information about the Python-list mailing list