Monday, September 5, 2011

time part of datetime not saved

I have a model start = models.DateTimeField()

In my view I create a datetime:
x = datetime.datetime(*(time.strptime(str(component.get('dtstamp')),'%Y
%m%dT%H%M%SZ')[0:6])) .

This return a valid datetime:
>>> x
datetime.datetime(2011, 9, 4, 8, 45, 32)

The problem is that only the date part is saved in the database. The
time is saved as zero's:
>>> db.created
datetime.datetime(2011, 9, 4, 0, 0)

Do i need to convert the date before saving it into the database?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment