Ordinal date format (YYYY-DDD)

By dkl9, written 2023-177, revised 2023-223 (2 revisions)

You may be used to dates written in terms of a year, a month, and a day. Ideally, this is expressed in ISO 8601's YYYY-MM-DD (as in 2023-06-26).

We may instead express dates in terms of a year and a day-of-the-year, with no month. The day goes from 1 to 365 (or 366 in leap years). This is the "ordinal date" format: YYYY-DDD (as in 2023-177).

Ordinal dates are more compact than the traditional form. The traditional form uses up to 8 digits (4 for year + 2 for month + 2 for day), and is sometimes made longer by the use of month names. Ordinal dates are consistently 7 digits.

Ordinal dates are easier to operate on. You can subtract two dates to figure out the number of days between them — a common operation — by just subtracting the day-numbers. The procedure only gets more complicated when the dates are in different years. Traditional dates complicate that procedure much more frequently: at every month boundary.

Ordinal dates better reflect the physical world. Months, as used in the Gregorian calendar, are arbitrary. They're loosely based on the orbit of the moon, but they don't reflect it closely enough to be useful in that way. Unlike weeks (which aren't included as part of numeric dates anyway), months don't even enforce a consistent spacing. Only the year and the day have an accurately-modeled physical basis, at least in the Gregorian calendar.

Markus Kuhn lists ten advantages of ISO 8601's YYYY-MM-DD format. YYYY-DDD shares all of those advantages except the 8th and 9th.

The only real disadvantage to ordinal dates is current unpopularity. But they're already endorsed by the ISO 8601 date and time standard, and can be accessed in at least some software with some configuration. Any program using percent-based notation to configure date formats (such as the date shell utility) should accept %Y-%j as directions to show ordinal dates.

§ Tools

Today is ... (reload to update).

Enter a date:

As an ordinal date, that's ....

Unix shell commands: