Month/Year (slash-separated)
datetime.date.month_year_slashNumeric Month/Year with slash separator. No day component. Accepts both MM/YYYY and MM/YY formats. Common in billing data, credit card expiration dates, and financial periodization.
Operations on this type: Parse a date or time, Parse nested values
Try a value
Month/Year (slash-separated)'s rule accepts it.
Reads it as 2024-03-01
Use it
finetype infer -i '01/2024' --mode column
# → datetime.date.month_year_slashSELECT ft_infer('01/2024');
-- → 'datetime.date.month_year_slash'CASE WHEN LENGTH({col}) = 5 THEN strptime('01/' || SUBSTRING({col}, 1, 2) || '/20' || SUBSTRING({col}, 4, 2), '%d/%m/%Y')::DATE ELSE strptime('01/' || {col}, '%d/%m/%Y')::DATE END
-- Format: %m/%YHow finetype reads the samples
DuckDB 1.5.5 · finetype 0.6.66
| Value | As DATE | month | year |
|---|---|---|---|
| 01/2024 | 2024-01-01 | 1 | 2024 |
| 12/2023 | 2023-12-01 | 12 | 2023 |
| 06/2000 | 2000-06-01 | 6 | 2000 |
| 12/25 | 2025-12-01 | 12 | 2025 |
| 03/26 | 2026-03-01 | 3 | 2026 |
- %m
- month, two digits
- %Y
- four-digit year
Pattern
Length 5 to 7 characters.
^(0[1-9]|1[0-2])/(\d{2}|\d{4})$| Value | Length | Shape |
|---|---|---|
| 01/2024 | 7 | matches |
| 12/2023 | 7 | matches |
| 06/2000 | 7 | matches |
| 12/25 | 5 | matches |
| 03/26 | 5 | matches |
| 01/202 | 6 | rejected: one character short |
Background
Origin
ISO/IEC 7813 is an international standard that defines properties of financial transaction cards, such as ATM or credit cards.[1] Wikipedia's article on ISO/IEC 7813 gives the embossed expiration date of a card in the format MM/YY or MM-YY.[1] A payment card's expiry date is displayed on the front of the card in MM/YY format and is also stored electronically on a magnetic stripe or chip.[2]
Use
The HTML Standard notes that a credit card expiry date can be expressed as one field giving both the month and year of expiry, or as two fields, one giving the month and one the year.[3] In the HTML Standard, the canonical format of the cc-exp autofill field is a valid month string, with the example 2014-12.[3] Stripe's API describes a card's exp_month as a two-digit number representing the expiration month and exp_year as a four-digit number representing the expiration year.[4] Be ready for both MM/YY and MM/YYYY in one column, since a value copied from the card face and one assembled from separate month and year fields can differ in length. (Meridian's view)
Python's time documentation says that two-digit years parsed with %y are converted according to the POSIX and ISO C standards, with values 69–99 mapped to 1969–1999 and values 0–68 mapped to 2000–2068.[5] Decide the century of a two-digit year yourself and write the rule down, rather than leaving it to whatever pivot a parsing library happens to apply. (Meridian's view) A short value such as 12/25 could just as well be a month and a day, so confirm from the column name or its neighbours that the part after the slash is a year before you cast it. (Meridian's view) Casting to the first day of the month gives a handy key for sorting and joining, but an expiry or billing value names the whole month, not that single day. (Meridian's view)
Sources
- [1]ISO/IEC 7813secondary source
- [2]Expiration date, expiry datesecondary source
- [3]HTML Standardstandard
- [4]The Card objectdocumentation
- [5]time — Time access and conversions — Python 3.15.0 documentationdocumentation
How it's detected
Billing data, financial periodization. Widened to accept MM/YY format (credit card expiration dates) after collapsing finance.payment.credit_card_expiration_date into this type.
Schema
https://meridian.online/schemas/datetime.date.month_year_slash · Frictionless type date · %m/%Y
finetype taxonomy datetime.date.month_year_slash -o json-schema