1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #28103 -- Added quarter extract, truncation, and lookup.

Thanks Mariusz Felisiak, Tim Graham, and Adam Johnson for review.
This commit is contained in:
Mads Jensen
2017-06-08 21:15:29 +02:00
committed by Tim Graham
parent f6bd00131e
commit c7f6ffbdcf
9 changed files with 202 additions and 17 deletions

View File

@@ -2830,6 +2830,28 @@ When :setting:`USE_TZ` is ``True``, datetime fields are converted to the
current time zone before filtering. This requires :ref:`time zone definitions
in the database <database-time-zone-definitions>`.
.. fieldlookup:: quarter
``quarter``
~~~~~~~~~~~
.. versionadded:: 2.0
For date and datetime fields, a 'quarter of the year' match. Allows chaining
additional field lookups. Takes an integer value between 1 and 4 representing
the quarter of the year.
Example to retrieve entries in the second quarter (April 1 to June 30)::
Entry.objects.filter(pub_date__quarter=2)
(No equivalent SQL code fragment is included for this lookup because
implementation of the relevant query varies among different database engines.)
When :setting:`USE_TZ` is ``True``, datetime fields are converted to the
current time zone before filtering. This requires :ref:`time zone definitions
in the database <database-time-zone-definitions>`.
.. fieldlookup:: time
``time``