Skip to content
Learn › Clean and shape data › Convert column types: open the docs menu

Convert text to a date with format codes

To turn a text column into a date, use Convert Column Type, choose Date, and click Define Source Format (the gear icon) to say what the text looks like. With Source - Auto, Mammoth samples the column's values and detects the formats present, which works for most real-world data. For ambiguous, uncommon or mixed formats, choose a source format or give format codes. Values that don't match become empty (NULL).

Tell Mammoth the order of day and month

A date made only of numbers, such as 01/02/2025, could be 2 January (US) or 1 February (UK). Choose the source format to settle it:

OptionReads 01/02/2025 asUse when
Source - AutoDetected from your data; may guess wrongYour dates are mostly unambiguous (month names or clear patterns)
Source - DD/MM/YYYY (Day First)1 February 2025Dates are always day first
Source - MM/DD/YYYY (Month First)2 January 2025Dates are always month first
Source - Custom (multiple formats)Your format codesMixed formats or non-standard patterns

If your dates are ambiguous, always choose Day First or Month First rather than Auto, to prevent silent parsing errors.

Date format codes for text dates

Mammoth reads text using PostgreSQL-style format codes:

CodeMeaningExampleNotes
YYYY4-digit year2025Use YY for 2-digit years (25)
MMMonth (01-12)01
DDDay of month (01-31)15
HH24Hour (24-hour, 00-23)14Use HH12 or HH for 12-hour format (01-12)
MIMinute (00-59)30
SSSecond (00-59)45
MON / MONTHMonth nameJan / JanuaryMON is abbreviated, MONTH is full. Write the code in upper, title or lower case: MON, Mon, mon, MONTH, Month, month
DAY / DYWeekday nameWednesday / WedDAY is the full name, DY a 3-letter abbreviation. Upper, title or lower case
AM / PMAM/PM indicatorAMWrite it AM, am, PM, pm, A.M., a.m., P.M. or p.m.
TZTime zone nameUTCA time zone abbreviation, such as PST, EST or UTC
OFTime zone offset+00:00±HH:MM or ±HHMM
Literal "T"The letter TTMatches the T in ISO format (2025-01-15T14:30:00)
Literal "Z"The letter ZZMatches the ISO Zulu indicator (2025-01-15T14:30:00Z)

Common date formats and their codes

FormatFormat codeInputResult
ISOYYYY-MM-DD2025-01-15January 15, 2025
ISO 8601 with timeYYYY-MM-DD"T"HH24:MI:SS"Z"2025-01-15T14:30:45ZJanuary 15, 2025 2:30:45 PM (UTC)
US (month/day/year)MM/DD/YYYY01/15/2025January 15, 2025
UK (day/month/year)DD/MM/YYYY15/01/2025January 15, 2025
Long, with month nameDD MONTH YYYY15 January 2025January 15, 2025
European (day.month.year)DD.MM.YYYY15.01.2025January 15, 2025

Convert a column that mixes date formats

Choose Source - Custom (multiple formats) and enter several format codes separated by semicolons:

Format: YYYY-MM-DD; MM/DD/YYYY; DD.MM.YYYY

Mammoth tries each format in order until one works. This helps with data imported from several sources, history where the format changed over time, and inconsistent data entry.

Troubleshooting text to date conversions

ProblemCauseFix
All cells become emptyThe format code doesn't match your dataCheck the real date format in the source. Try Source - Auto first.
Some cells are emptySome values don't match the formatLook for typos, extra spaces or inconsistent formats in those rows.
"01/02/2025" reads wrongAmbiguous US or UK dateChoose Day First or Month First instead of Auto.
Extra text after the date ("2025-01-15 extra text")The format covers only the dateThat's fine: the format only needs to match the date part. Extra characters are ignored.
"2025-01-15 14:30:00" doesn't convertThe format has no time partUse YYYY-MM-DD HH24:MI:SS.

If Auto fails on a copy of the column, the data itself may have typos, mixed formats or invalid dates.

If Auto fails on a copy of the column, the data itself may have typos, mixed formats or invalid dates.

Was this page helpful?

Something wrong? support@mammoth.io