Opened 7 years ago

Closed 2 years ago

#12489 closed New feature (fixed)

Need a Field Lookup for day of year: __dayofyear

Reported by: Dean Quinanola Owned by: v1v3kn
Component: Database layer (models, ORM) Version:
Severity: Normal Keywords: field lookup datetime filter
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The current built-in year, month, day, week_day Field Lookups do not directly help if you need to find rows that are on a specific date. In SQL, there is a DAYOFYEAR(). It would be useful to have a Field Lookup that pairs this function with python datetime's %j directive

Attachments (2)

django12489.docs.diff (1.3 KB) - added by v1v3kn 6 years ago.
Documentation for the patch
django12489.diff (7.2 KB) - added by v1v3kn 6 years ago.
Implemented day_of_year & week_of_year with tests

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted
Version: 1.1

DAY_OF_YEAR is starting to get a bit esoteric, but I can't see any harm providing it, along with it's analogs WEEK and WEEK_OF_YEAR.

Related: #8424 describes adding HOUR/MINUTE/SECOND filters.

comment:2 Changed 6 years ago by v1v3kn

Owner: changed from nobody to v1v3kn
Status: newassigned

comment:3 Changed 6 years ago by v1v3kn

Has patch: set

comment:4 Changed 6 years ago by Łukasz Rekucki

Needs documentation: set

Changed 6 years ago by v1v3kn

Attachment: django12489.docs.diff added

Documentation for the patch

comment:5 Changed 6 years ago by v1v3kn

Needs documentation: unset

comment:6 Changed 6 years ago by v1v3kn

milestone: 1.3

comment:7 Changed 6 years ago by Russell Keith-Magee

milestone: 1.31.4

This is a feature addition, and the deadline for new features in 1.3 passed some time ago.

Changed 6 years ago by v1v3kn

Attachment: django12489.diff added

Implemented day_of_year & week_of_year with tests

comment:8 Changed 5 years ago by Matt McClanahan

Severity: Normal
Type: New feature

comment:9 Changed 5 years ago by Jannis Leidel

Easy pickings: unset
Needs documentation: set

comment:10 Changed 5 years ago by Ulrich Petri

UI/UX: unset

Related: #16187 Refactor of the lookup system

comment:11 Changed 5 years ago by Jacob

milestone: 1.4

Milestone 1.4 deleted

comment:12 Changed 2 years ago by Aymeric Augustin

Resolution: fixed
Status: assignedclosed

The custom lookups introduced in Django 1.7 can be used to implement this feature.

See https://docs.djangoproject.com/en/1.7/ref/models/custom-lookups/

Note: See TracTickets for help on using tickets.
Back to Top