#7672: Add filter for 'Day of week' on Date / DateTime fields
---------------------------------------------+------------------------------
          Reporter:  rossp                   |         Owner:  nobody  
            Status:  new                     |     Milestone:  post-1.0
         Component:  Database wrapper        |       Version:  SVN     
        Resolution:                          |      Keywords:          
             Stage:  Design decision needed  |     Has_patch:  1       
        Needs_docs:  0                       |   Needs_tests:  0       
Needs_better_patch:  1                       |  
---------------------------------------------+------------------------------
Comment (by rossp):

 For reference, I've just done some investigation on the different date
 structures used in Python & the various database engines. I'm beginning to
 see why this isn't as easy as at face value :)

 {{{
 Method                              Range
 ------                              -----
 PYTHON
     datetime_object.weekday()       0-6    Sunday=6
     datetime_object.isoweekday()    1-7    Sunday=7
     dt_object.isoweekday() % 7      0-6    Sunday=0 # Can easily add 1 for
 a 1-7 week where Sunday=1

 MYSQL
     DAYOFWEEK(timestamp)            1-7    Sunday=1
     WEEKDAY(timestamp)              0-6    Monday=0

 POSTGRES
     EXTRACT('dow' FROM timestamp)   0-6    Sunday=0
     TO_CHAR(timestamp, 'D')         1-7    Sunday=1

 ORACLE
     TO_CHAR(timestamp, 'D')         1-7    Sunday=1 (US), Sunday=6 (UK)
 }}}

 I'm thinking it will be easier to assume 1-7 with Sunday=1 and use the
 relevant functions from above, although I'm unsure at this stage of the
 best way to handle Oracle as I don't have access to an Oracle server to
 test on. Do we know the current Oracle date locale config from within
 Django at runtime?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7672#comment:3>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to