#28649: Add "week_year" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
               Reporter:  Sigurd     |          Owner:  nobody
  Ljødal                             |
                   Type:  New        |         Status:  assigned
  feature                            |
              Component:  Database   |        Version:  master
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  ORM Extract
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I found myself in the need to extract the ISO year/week-numbering year (as
 specified by ISO 8601) from a date/datetime field, e.g. to group values by
 week. This is easy with PostgreSQL:

 {{{
 from django.db.models.functions import Extract, ExtractWeek

 SomeModel.objects.annotate(
     year=Extract('some_date', 'isoyear'),
     week=ExtractWeek('some_date'),
 ).values(
     'year', 'week',
 ).annotate(
     sum=Sum('some_field'),
 )
 }}}

 but unfortunately this does not work across databases. I've implemented an
 `ExtractWeekYear` class with support for all databases and will submit a
 pull request shortly.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28649>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.1636aedfb60c008c57270e3ec3193bc6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to