johnny wrote:
> My model named: Post
> 
> It has a field created_at as:
> created_at = models.DateTimeField(auto_now_add = True)
> 
> Would Post.created_at be of string or datetime ?
> 
> I want to add 2 weeks to it, like Post.created_at + 14 days.  Can I do
> this?
> Post.created_at =Post.created_at + datetime.timedelta(weeks=2)
> 
If you are going to be doing date math, may as well get into 
http://labix.org/python-dateutil

 >>> from datetime import date
 >>> from dateutil.relativedelta import relativedelta
 >>> created_at=date.today()
 >>> created_at + relativedelta(weeks=+2)
datetime.date(2007, 7, 17)

It is easy enough to convert weeks to days, but when you get into working with 
months, dateutil comes in really handy.

Carl K

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to