Dates & time
Scalar
try_strptime()
Converts the string text to timestamp according to the format string. Returns NULL on failure.
Reference: Haybarn WASM 2.0.0-rc12
Arguments & returns
2 overloadstry_strptime(text, format)
Scalar
Parse dates without stopping on bad input
Parse text into a timestamp with an explicit format, returning NULL when a value cannot be parsed.
Invalid text and NULL input both produce NULL. This lets a query retain rows that need cleaning.
Haybarn WASM 2.0.0-rc12 · In your browser
Guide example · Run to view results.
| input | parsed |
|---|---|
06/11/2026 | 2026-11-06 |
bad date | NULL |
NULL | NULL |
Watch for: A NULL result does not distinguish missing input from malformed input. Keep the original text when auditing parsing failures.
Example
Haybarn WASM 2.0.0-rc12 · In your browser
Engine example · Run to view results.
In other engines
Apache Sparkto_date()
TO_DATE(x, 'yyyy')
CAST(CAST(TRY_STRPTIME(x, '%Y') AS TIMESTAMP) AS DATE)
BigQuerysafe_cast()
SAFE_CAST(some_date AS DATE FORMAT 'DD MONTH YYYY')
CAST(TRY_STRPTIME(some_date, '%d %B %Y') AS DATE)
Snowflaketry_to_time()
SELECT TRY_TO_TIME('093000', 'HH24MISS')
SELECT TRY_CAST(TRY_STRPTIME('093000', '%H%M%S') AS TIME)