Compact Date (DDMMYYYY)
datetime.date.compact_dmywas date.numeric_dmy in v1Eight-digit date with no separators, day-first.
Worked samples
DuckDB 1.5.5 · finetype 0.6.64
| Value | As DATE |
|---|---|
| 15012024 | 2024-01-15 |
| 31122019 | 2019-12-31 |
- %d
- day of month, two digits
- %m
- month, two digits
- %Y
- four-digit year
Shape
^(0[1-9]|[12]\d|3[01])(0[1-9]|1[0-2])\d{4}$| Value | Length | Shape |
|---|---|---|
| 15012024 | 8 | matches |
| 31122019 | 8 | matches |
| 1501202 | 7 | rejected: one character short |
Background
Origin
The METeOR value domain Date DDMMYYYY gives its format as DDMMYYYY with a maximum character length of 8.[1] METeOR defines the Date DDMMYYYY value domain as the day of a particular month and year.[1] The Australian Institute of Health and Welfare is named on METeOR as the submitting organisation for the Date DDMMYYYY value domain.[1] METeOR records the Date DDMMYYYY value domain as a Health standard from 01/03/2005.[1]
SAS documents a DDMMYYxw. format in which the letter x chooses the separator between day, month and year.[2] In the SAS DDMMYYxw. format, the value N indicates no separator.[2] SAS's own sample on date formats says the formats that let a programmer choose the separator, or no separator, arrived in SAS Version 7.[3]
Use
The SAS documentation shows put date ddmmyyn8. writing the date 24 May 2012 as 24052012.[2] METeOR's date of birth element recommends that self-reported forms collect the date as _ _ / _ _ / _ _ _ _, which it says enables easy conversion to the preferred representational layout (DDMMYYYY).[4] METeOR notes that national health and community services collections typically use 0101, 0107 or 3006 as the estimate or default for DDMM when a date of birth is estimated or a default value.[4] In collections that use those defaults, a cluster of birth dates beginning 0101, 0107 or 3006 is worth checking against a date accuracy flag before treating them as real birthdays. (Meridian's view)
A compact day-first date cannot be told apart from a compact month-first one when the day is 12 or less, so 01022024 could be 1 February or 2 January. (Meridian's view)
Read the whole column before choosing an order: one value whose first two digits exceed 12 rules out month-first, and one whose middle pair exceeds 12 rules out day-first. (Meridian's view)
Keep compact dates as text from the moment they are loaded. (Meridian's view)
Microsoft's guide for Excel for the web says Excel removes leading zeros from numbers typed with them, and suggests applying the Text format to the cells before typing or pasting.[5]
Python's datetime documentation says that, with strptime(), the leading zero is optional for %d and %m.[6] Check that every value is exactly eight digits before parsing with %d%m%Y, rather than trusting the parser to reject a value that has lost a digit. (Meridian's view)
Where you'll meet it
METeOR's Person—date of birth, DDMMYYYY data element defines date of birth as the date of birth of the person, expressed as DDMMYYYY.[4] METeOR lists the Person—date of birth, DDMMYYYY data element as a standard for registration authorities including Health, Disability, Youth Justice and Aged Care.[4]
Sources
- [1]Date DDMMYYYYdocumentation
- [2]DDMMYYx Format :: SAS(R) 9.3 Formats and Informats: Referencedocumentation
- [3]24610 - SAS date formats with or without separatorsdocumentation
- [4]Person—date of birth, DDMMYYYYorganisation
- [5]Format numbers to keep leading zeros in Excel for the web | Microsoft Supportdocumentation
- [6]datetime — Basic date and time types — Python 3.15.0 documentationdocumentation
Detection notes
v1 name: date.numeric_dmy. Same regex as compact_ymd/compact_mdy. COLUMN_MODE_DISAMBIGUATION_TARGET: compact_dmy vs compact_mdy vs compact_ymd
Use it
$ finetype infer -i "15012024" --mode column
→ datetime.date.compact_dmy
SELECT ft_infer('15012024');
-- → 'datetime.date.compact_dmy'strptime({col}, '%d%m%Y')::DATE
-- Format: %d%m%YSchema
https://meridian.online/schemas/datetime.date.compact_dmy · Frictionless type date · %d%m%Y
finetype taxonomy datetime.date.compact_dmy -o json-schema