On 7 Sep 2009, at 15:50 , Rob B (uk) wrote:
http://dpaste.com/90621/
> (The code in above obviously isn't going to work I'm just using it to
> help illustrate my problem.)
>
> I want to show all active promotions between the start date and end
> date.
> So if a promotion starts on 01/01/09 and ends 30/01/09 and a person
> searches from 01/12/08 to 01/02/09 it will still return a result. Also
> if they search from inside the date range e.g. 02/01/09 - 03/01/09
> they would get the same result.
>
> Is there some magical django way of achieving this without looping
> over each day?

Something along the lines of:

     Promotion.objects.filter(start_date__lt=end_date,  
end_date__gt=start_date)

I'd think.

--~--~---------~--~----~------------~-------~--~----~
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