Meridianmeridian

Year-Month (ISO truncated)

datetime.date.year_month

ISO 8601 truncated form with no day component. Pervasive in monthly time-series data, financial reporting, and API responses. Transforms to first day of month.

Domain
datetime
Category
date
Casts to
DATE
Scope
Universal

Try it

CLI
$ finetype infer -i "2024-01"
→ datetime.date.year_month

DuckDB

Detect
SELECT finetype('2024-01');
-- → 'datetime.date.year_month'
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.year_month';

Struct Expansion

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

JSON Schema

finetype schema datetime.date.year_month
{
  "$id": "https://meridian.online/schemas/datetime.date.year_month",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "ISO 8601 truncated form with no day component. Pervasive in monthly time-series data, financial reporting, and API responses. Transforms to first day of month.",
  "examples": [
    "2024-01",
    "2023-12",
    "2000-06"
  ],
  "maxLength": 7,
  "minLength": 7,
  "pattern": "^\\d{4}-\\d{2}$",
  "title": "Year-Month (ISO truncated)",
  "type": "string",
  "x-finetype-broad-type": "DATE",
  "x-finetype-format-string": "%Y-%m",
  "x-finetype-transform": "strptime({col} || '-01', '%Y-%m-%d')::DATE"
}

Examples

2024-012023-122000-06

Aliases

yearmonth