[EMAIL PROTECTED] wrote:
> I don't know if I'm just confused or if it's a bug in Django, but
> here's a little bit of code I put in a shell:
>
>>>> sunday = datetime.date(2006, 12, 3)
>>>> saturday = sunday + datetime.timedelta(days=6)
>>>> next_sunday = sunday + datetime.timedelta(days=7)
>>>> for day in (sunday, saturday, next_sunday): print day.strftime("%A,
>>>> %d-%b-%Y")
> ...
> Sunday, 03-Dec-2006
> Saturday, 09-Dec-2006
> Sunday, 10-Dec-2006
>>>> e.get_messages().filter(date_saisie__gte=sunday,
>>>> date_saisie__lte=saturday).count()
> 63L
>>>> e.get_messages().filter(date_saisie__gte=sunday,
>>>> date_saisie__lt=next_sunday).count()
> 68L
>
> Why the difference in the number of messages found? Isn't "<=
> saturday" equivalent to "< next_sunday"?
I'd suspect your database data type is tripping you up. I would verify
that your database handles date comparisons the way you think it does.
The first django filter above would equate roughly to:
WHERE date_saisie >= '2006-12-03' AND date_saisie <= '2006-12-09'. I
use postgresql which I think would interpret this as "from '2006-12-03
00:00:00' to '2006-12-09 00:00:00'". And the second one: "from
'2006-12-03 00:00:00' to '2006-12-10 00:00:00". The second form
includes all TIMES after 'saturday' started until the end of that day.
The first form doesn't include TIMES after the very beginning of 'saturday'.
Eric.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---