You dont mention the database you use if mysql you could do

SELECT * FROM <table> WHERE DATE_FORMAT(<date field>, "%u") = DATE_FORMAT(curdate(), "%u")

dont know if there is a django orm way to do it, but could always use a raw query.

Am 05.01.2012 21:14, schrieb Tim Sawyer:
Hi Folks,

Does anyone have a strategy for selecting from a database where the date is this week, but a random year in the past?

I have ~100 years of events in a database, each with a datefield - I would like to do a "this week in history" box that lists one or two on the homepage, randomly taken from the set.

Ideas/pointers appreciated.

Cheers,

Tim.


--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to