{{{
class ExtractQuarter(Extract):
lookup_name = "quarter"
DateField.register_lookup(ExtractQuarter)
}}}
You probably also want to add a corresponding Trunc function, though I
haven't tested it.
{{{
class TruncQuarter(TruncBase):
kind = "quarter"
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28103>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* version: 1.11 => master
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:1>
* cc: felixxm (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:2>
Comment (by felixxm):
You can take a look at very similar #25240 ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:3>
* owner: nobody => Mads Jensen
* status: new => assigned
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/8382 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:4>
* needs_better_patch: 0 => 1
* easy: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:5>
Comment (by Mads Jensen):
Oracle and PostgreSQL have built-in functionality for truncating a date to
the first month of a quarter. However, in Oracle, it rounds up
(https://docs.oracle.com/database/121/SQLRF/functions271.htm#SQLRF52058)
and in PostgreSQL, it's always rounded down
(https://www.postgresql.org/docs/current/static/functions-datetime.html
#FUNCTIONS-DATETIME-TRUNC). Neither SQLite or MySQL has a convenient
built-in functionality and it's a matter of interpretation.
The Extract functionality is implemented, and has the same behavior on all
backends.
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:6>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"c7f6ffbdcf9ca8df905aebf73336ef9905771f7c" c7f6ffbd]:
{{{
#!CommitTicketReference repository=""
revision="c7f6ffbdcf9ca8df905aebf73336ef9905771f7c"
Fixed #28103 -- Added quarter extract, truncation, and lookup.
Thanks Mariusz Felisiak, Tim Graham, and Adam Johnson for review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:8>