Meridianmeridian

Compact Year-Month (YYYYMM)

datetime.date.compact_ym

6-digit compact year-month with no separators. Data warehouse period keys, financial reporting codes. Could collide with 6-digit integers — requires header/context hints.

Domain
datetime
Category
date
Casts to
DATE
Scope
Universal

Try it

CLI
$ finetype infer -i "202401"
→ datetime.date.compact_ym

DuckDB

Detect
SELECT finetype('202401');
-- → 'datetime.date.compact_ym'
Cast expression
strptime({col} || '01', '%Y%m%d')::DATE
-- Format: %Y%m
Safe cast pipeline
-- Normalise and cast in one step
SELECT TRY_CAST(finetype_cast(my_column) AS DATE) AS clean_value
FROM my_table
WHERE finetype(my_column) = 'datetime.date.compact_ym';

Struct Expansion

Expression
month: CAST(SUBSTRING({col}, 5, 2) AS INT)
year: CAST(SUBSTRING({col}, 1, 4) AS INT)

JSON Schema

finetype schema datetime.date.compact_ym
{
  "$id": "https://meridian.online/schemas/datetime.date.compact_ym",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "6-digit compact year-month with no separators. Data warehouse period keys, financial reporting codes. Could collide with 6-digit integers — requires header/context hints.",
  "examples": [
    "202401",
    "202312",
    "200006"
  ],
  "maxLength": 6,
  "minLength": 6,
  "pattern": "^\\d{4}(0[1-9]|1[0-2])$",
  "title": "Compact Year-Month (YYYYMM)",
  "type": "string",
  "x-finetype-broad-type": "DATE",
  "x-finetype-format-string": "%Y%m",
  "x-finetype-transform": "strptime({col} || '01', '%Y%m%d')::DATE"
}

Examples

202401202312200006