On Tue, Jan 26, 2010 at 9:14 AM, Henrik Genssen <h...@mediafactory.de> wrote:

> how would I extend the field lookup to get somethnng like this:
>
> SELECT ... WHERE EXTRACT('hour' FROM pub_date) > 20
> what is for MYSQL:
> SELECT ... WHERE HOUR(pub_date) > 20
> to get all entries where the timepart of pub_date is grater then 8pm
>
>
Have a look at the extra() method on the queryset -
http://docs.djangoproject.com/en/1.1/ref/models/querysets/#queryset-api

With that you can inject the relevant SQL to extract a part of a datetime
field and filter by < > = etc.

Alternatively, store your table with the datetime split into year, month,
day, hour, minute etc fields.  You could add processing to the model's
save() function to do this transparently.

 As far as I know there's no built-in way to do what you want.

Cheers,

Malcolm

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

Reply via email to