try_to_time Função

Aplica-se a:check marked yes Databricks SQL check marked yes Databricks Runtime 18.3 and above

Retorna expr a conversão para um tempo usando uma formatação opcional ou NULL se a conversão falhar.

Syntax

try_to_time(expr [, fmt] )

Arguments

  • expr: uma expressão STRING que representa um tempo.
  • fmt: uma expressão STRING de formatação opcional.

Returns

UM TEMPO.

Se fmt for fornecido, ele deverá estar em conformidade com os padrões de datetime.

Se fmt não for fornecido, a função será equivalente a cast(expr AS TIME).

Se fmt estiver malformado, Azure Databricks aumentará INVALID_DATETIME_PATTERN.

Se expr não puder ser transformado em um tempo usando fmt, a função retornará NULL.

Condições de erro comuns

Exemplos

> 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