Funzione try_to_time

Si applica a:check contrassegnato come sì controllo SQL di Databricks contrassegnato come sì Databricks Runtime 18.3 e versioni successive

Restituisce expr il cast a un'ora usando una formattazione facoltativa o NULL se il cast ha esito negativo.

Syntax

try_to_time(expr [, fmt] )

Arguments

  • expr: espressione STRING che rappresenta un'ora.
  • fmt: espressione STRING di formato facoltativa.

Returns

UN'ORA.

Se fmt viene specificato, deve essere conforme ai modelli Datetime.

Se fmt non viene specificato, la funzione equivale a cast(expr AS TIME).

Se fmt non è valido, Azure Databricks genera INVALID_DATETIME_PATTERN.

Se expr non può essere trasformato in un'ora usando fmt, la funzione restituisce NULL.

Condizioni di errore comuni

Examples

> SELECT try_to_time('10:30:00');
  10:30:00

> SELECT try_to_time('10:30:00', 'HH:mm:ss');
  10:30:00

> SELECT try_to_time('not-a-time');
  NULL

> SELECT try_to_time('10:30:00', 'HH:mm:ss') IS NOT NULL;
  true