TRY_TO_TIMESTAMP (Lakehouse v1)
A variant of TO_TIMESTAMP in PlaidCloud Lakehouse that, while performing the same conversion of an input expression to a timestamp, incorporates error-handling support by returning NULL if the conversion fails instead of raising an error.
See also: TO_TIMESTAMP
Analyze Syntax
Section titled “Analyze Syntax”func.try_to_timestamp(<expr>)Analyze Examples
Section titled “Analyze Examples”func.try_to_timestamp('2022-01-02 02:00:11'), func.try_to_datetime('2022-01-02 02:00:11'), func.try_to_timestamp('plaidcloud')┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ func.try_to_timestamp('2022-01-02 02:00:11') │ func.try_to_datetime('2022-01-02 02:00:11') │ func.try_to_timestamp('plaidcloud') ││ Timestamp │ Timestamp │ │├─────────────────────────────────────────┼──────────────────────────────────────────────────┤─────────────────────────────────────││ 2022-01-02 02:00:11 │ 2022-01-02 02:00:11 │ NULL │└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘SQL Syntax
Section titled “SQL Syntax”-- Convert a string or integer to a timestampTRY_TO_TIMESTAMP(<expr>)
-- Convert a string to a timestamp using the given patternTRY_TO_TIMESTAMP(<expr, expr>)Aliases
Section titled “Aliases”SQL Examples
Section titled “SQL Examples”SELECT TRY_TO_TIMESTAMP('2022-01-02 02:00:11'), TRY_TO_DATETIME('2022-01-02 02:00:11');
┌──────────────────────────────────────────────────────────────────────────────────┐│ try_to_timestamp('2022-01-02 02:00:11') │ try_to_datetime('2022-01-02 02:00:11') ││ Timestamp │ Timestamp │├─────────────────────────────────────────┼────────────────────────────────────────┤│ 2022-01-02 02:00:11 │ 2022-01-02 02:00:11 │└──────────────────────────────────────────────────────────────────────────────────┘
SELECT TRY_TO_TIMESTAMP('databend'), TRY_TO_DATETIME('databend');
┌────────────────────────────────────────────────────────────┐│ try_to_timestamp('databend') │ try_to_datetime('databend') │├──────────────────────────────┼─────────────────────────────┤│ NULL │ NULL │└────────────────────────────────────────────────────────────┘