MeridianMERIDIAN

ISO Week Date

datetime.date.iso_weekwas datetime.week_date in v1

ISO 8601 week date format (YYYY-Www). Used in business planning, fiscal calendars, and European retail analytics.

Worked samples

DuckDB 1.5.5 · finetype 0.6.64

ValueAs DATE
2024-W032024-01-15
2019-W522019-12-23
%G
ISO week year
%V
ISO week number

Shape

Pattern
^\d{4}-W\d{1,2}$
ValueLengthShape
2024-W038matches
2019-W528matches
2024-W0339rejected: one character extra

Background

Origin

The ISO week date system is part of the ISO 8601 date and time standard, which the International Organization for Standardization has issued since 1988.[1] Before ISO 8601, the week date system was defined in ISO (R) 2015, from 1971.[1] The ISO week date system was previously known as Industrial date coding.[1]

ISO 8601 writes a week without its weekday as YYYY-Www, or as YYYYWww without the hyphen.[2] ISO weeks start on Monday and end on Sunday.[1] Week 01 of an ISO year is the week that contains 4 January.[2][3] An ISO week-numbering year has 52 or 53 full weeks.[1][3]

In ISO 8601, a 1 January that falls on a Friday, Saturday or Sunday is in week 52 or 53 of the previous year.[2] ISO 8601 writes Monday 29 December 2008 as 2009-W01-1.[2]

Use

The ISO week date system is used mainly in government and business for fiscal years, as well as in timekeeping.[1] Weeks are a prominent entity in accounting, where annual statistics benefit from regularity throughout the years.[1]

Python's strptime uses the ISO week directive %V only when the weekday and the ISO year directive %G are also in the format string.[3] Python's documentation warns that %G and %Y are not interchangeable.[3] Python added the %G, %u and %V directives in version 3.6.[3] DuckDB's documentation says %V is incompatible with the year directive %Y and to use the ISO year %G instead.[4] In PostgreSQL's to_date, an ISO 8601 week-numbering date can be given as year, week number and weekday, and an omitted weekday is assumed to be 1 (Monday).[5] PostgreSQL's to_date rejects a mixture of ISO 8601 week-numbering fields and Gregorian date fields with an error.[5]

Python's %W directive is a different week number, which counts the days of a new year before its first Monday as week 0.[3] If a file's week numbers start at 00, or its weeks begin on Sunday, it is probably not using ISO weeks at all, and is worth checking before you parse it. (Meridian's view) Check that every week number is padded to two digits before you sort the labels as text. (Meridian's view)

Detection notes

v1 name: datetime.week_date. Transform appends '-1' (Monday) to produce a full week-date that strptime can parse.

Use it

CLI · DuckDB
$ finetype infer -i "2024-W03" --mode column
→ datetime.date.iso_week

SELECT ft_infer('2024-W03');
-- → 'datetime.date.iso_week'
Cast expression
strptime({col} || '-1', '%G-W%V-%u')::DATE
-- Format: %G-W%V

Schema

https://meridian.online/schemas/datetime.date.iso_week · Frictionless type date · %G-W%V

finetype taxonomy datetime.date.iso_week -o json-schema

Aliases

week_date

Type Registry