# try_strptime — Haybarn WASM 2.0.0-rc12

Converts the `string` text to timestamp according to the format string. Returns `NULL` on failure.

- Reference: /products/haybarn/functions/releases/haybarn-2.0.0-rc12/try_strptime/
- JSON: /products/haybarn/functions/api/v1/haybarn-2.0.0-rc12/functions/try_strptime.json
- Snapshot ID: haybarn-2.0.0-rc12
- Engine: haybarn v2.0.0
- Source ID: 9b1a0c5829
- Binary SHA-256: 07ab540b40e7dded86546a179f58276085900a44e92d1aa070072360c1f78ae6
- Captured: 2026-11-06T18:33:13.228Z
- Source: https://www.npmjs.com/package/@haybarn/haybarn-wasm/v/2.0.0-rc12
- Loaded extensions: core_functions, icu, json, nanoarrow, parquet

## Interpretation

- Choose a snapshot matching the target engine and build. The default is captured from the published Haybarn WASM package used by the browser playground. Historical native snapshots are also available.
- Availability is an observation in the recorded build and extension profile, not a guarantee of support in every installation or in WASM.
- Types and descriptions are declarations from duckdb_functions(). Binding can specialize result types. Null means not supplied by the catalog; do not invent defaults, optionality, argument mode, or table output columns.
- Raw parameter arrays preserve catalog order for scalar/aggregate/macro functions. Raw table arguments are alphabetical. Use callingConvention for engine-confirmed positional order and named arguments; null modes are unrecorded. Named does not mean optional. Macro defaults and special named variadic behavior are not supplied by duckdb_functions().
- Catalog examples are source material and may require data or extensions. runnableExamples contains separately verified SQL for the pinned WASM package; sample-data adaptations and guide examples are labeled separately.
- Guide annotations and recipes are separate editorial content. The browser runner always uses Haybarn WASM 2.0.0-rc12, independently of the documentation snapshot.
- All URLs beginning with / are relative to the origin hosting this document. Exports require no JavaScript, cookies, API key, or browser engine.

## Overloads

### overload-3b76814c891e7e6d

Kind: scalar. Parameter order: catalog-order.

```text
try_strptime(text: VARCHAR, format: VARCHAR) → TIMESTAMP
```

Link: /products/haybarn/functions/releases/haybarn-2.0.0-rc12/try_strptime/#overload-3b76814c891e7e6d

| Argument | Catalog type | Calling mode |
| --- | --- | --- |
| text | VARCHAR | not recorded |
| format | VARCHAR | not recorded |

Declared return type: TIMESTAMP. Variadic argument type: none declared.
Stability: CONSISTENT. Declared side effects: false.

### overload-395352e714e798e4

Kind: scalar. Parameter order: catalog-order.

```text
try_strptime(text: VARCHAR, format: VARCHAR[]) → TIMESTAMP
```

Link: /products/haybarn/functions/releases/haybarn-2.0.0-rc12/try_strptime/#overload-395352e714e798e4

| Argument | Catalog type | Calling mode |
| --- | --- | --- |
| text | VARCHAR | not recorded |
| format | VARCHAR[] | not recorded |

Declared return type: TIMESTAMP. Variadic argument type: none declared.
Stability: CONSISTENT. Declared side effects: false.


## 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.

Intended runtime: Haybarn WASM 2.0.0-rc12.

```sql
SELECT input, try_strptime(input, '%d/%m/%Y')::DATE AS parsed
FROM (VALUES ('06/11/2026'), ('bad date'), (NULL)) t(input)
ORDER BY input NULLS LAST;
```

Expected result:

| 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.


## Guide recipes

No guide recipes.

## Engine catalog examples

Source examples may require additional data or extensions. Expressions are wrapped in SELECT; execution verification is not recorded.

Reported for: overload-3b76814c891e7e6d, overload-395352e714e798e4

```sql
SELECT try_strptime('Wed, 1 January 1992 - 08:38:40 PM', '%a, %-d %B %Y - %I:%M:%S %p');
```

## Runnable examples

Executed successfully in Haybarn WASM 2.0.0-rc12. Sample data and guide examples are separate from the original catalog.

```sql
SELECT try_strptime('Wed, 1 January 1992 - 08:38:40 PM', '%a, %-d %B %Y - %I:%M:%S %p');
```

## Additional DuckDB documentation

- [Date Format Functions](https://duckdb.org/docs/current/sql/functions/dateformat)
- [Timestamp Functions](https://duckdb.org/docs/current/sql/functions/timestamp#try_strptimetext-format)

## In other engines

### Apache Spark: to_date()



Apache Spark:

```sql
TO_DATE(x, 'yyyy')
```

Haybarn / DuckDB:

```sql
CAST(CAST(TRY_STRPTIME(x, '%Y') AS TIMESTAMP) AS DATE)
```

Translation from [SQLGlot](https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_spark.py#L199).

### BigQuery: safe_cast()



BigQuery:

```sql
SAFE_CAST(some_date AS DATE FORMAT 'DD MONTH YYYY')
```

Haybarn / DuckDB:

```sql
CAST(TRY_STRPTIME(some_date, '%d %B %Y') AS DATE)
```

Translation from [SQLGlot](https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_bigquery.py#L645).

### Snowflake: try_to_time()



Snowflake:

```sql
SELECT TRY_TO_TIME('093000', 'HH24MISS')
```

Haybarn / DuckDB:

```sql
SELECT TRY_CAST(TRY_STRPTIME('093000', '%H%M%S') AS TIME)
```

Translation from [SQLGlot](https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_snowflake.py#L3979).

## Observed availability

| Snapshot | Observed | Overloads | JSON |
| --- | --- | --- | --- |
| haybarn-2.0.0-rc12 | present | 2 | [reference](/products/haybarn/functions/api/v1/haybarn-2.0.0-rc12/functions/try_strptime.json) |
| haybarn-2.0.0-rc11 | present | 2 | [reference](/products/haybarn/functions/api/v1/haybarn-2.0.0-rc11/functions/try_strptime.json) |
| haybarn-2.0.0-rc8 | present | 2 | [reference](/products/haybarn/functions/api/v1/haybarn-2.0.0-rc8/functions/try_strptime.json) |
| haybarn-1.5.5-rc3 | present | 2 | [reference](/products/haybarn/functions/api/v1/haybarn-1.5.5-rc3/functions/try_strptime.json) |
| haybarn-1.5.6-rc6 | present | 2 | [reference](/products/haybarn/functions/api/v1/haybarn-1.5.6-rc6/functions/try_strptime.json) |
| duckdb-2.0.0 | present | 2 | [reference](/products/haybarn/functions/api/v1/duckdb-2.0.0/functions/try_strptime.json) |
| duckdb-1.5.6 | present | 2 | [reference](/products/haybarn/functions/api/v1/duckdb-1.5.6/functions/try_strptime.json) |
| duckdb-1.5.5 | present | 2 | [reference](/products/haybarn/functions/api/v1/duckdb-1.5.5/functions/try_strptime.json) |
| duckdb-1.4.4 | present | 2 | [reference](/products/haybarn/functions/api/v1/duckdb-1.4.4/functions/try_strptime.json) |
| duckdb-1.3.2 | present | 2 | [reference](/products/haybarn/functions/api/v1/duckdb-1.3.2/functions/try_strptime.json) |

Engine catalog documentation is derived from MIT-licensed Haybarn and DuckDB. [Notices](/third-party-notices.txt).
