Opened 6 years ago

Closed 14 months ago

#12489 closed New feature (fixed)

Need a Field Lookup for day of year: __dayofyear

Reported by: deanq 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 4 years ago.
Documentation for the patch
django12489.diff (7.2 KB) - added by v1v3kn 4 years ago.
Implemented day_of_year & week_of_year with tests

Download all attachments as: .zip

Change History (14)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version 1.1 deleted

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 4 years ago by v1v3kn

  • Owner changed from nobody to v1v3kn
  • Status changed from new to assigned

comment:3 Changed 4 years ago by v1v3kn

  • Has patch set

comment:4 Changed 4 years ago by lrekucki

  • Needs documentation set

Changed 4 years ago by v1v3kn

Documentation for the patch

comment:5 Changed 4 years ago by v1v3kn

  • Needs documentation unset

comment:6 Changed 4 years ago by v1v3kn

  • milestone set to 1.3

comment:7 Changed 4 years ago by russellm

  • milestone changed from 1.3 to 1.4

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

Changed 4 years ago by v1v3kn

Implemented day_of_year & week_of_year with tests

comment:8 Changed 4 years ago by mattmcc

  • Severity set to Normal
  • Type set to New feature

comment:9 Changed 4 years ago by jezdez

  • Easy pickings unset
  • Needs documentation set

comment:10 Changed 4 years ago by UloPe

  • UI/UX unset

Related: #16187 Refactor of the lookup system

comment:11 Changed 4 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

comment:12 Changed 14 months ago by aaugustin

  • Resolution set to fixed
  • Status changed from assigned to closed

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