Nóta
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as shíniú isteach nó eolairí a athrú.
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as eolairí a athrú.
Applies to:
Databricks SQL
Databricks Runtime 18.3 and above
Returns expr cast to a time using an optional formatting.
Syntax
to_time(expr [, fmt] )
Arguments
expr: A STRING expression representing a time.- fmt: An optional format STRING expression.
Returns
A TIME.
If fmt is supplied, it must conform with Datetime patterns.
If fmt is not supplied, the function is equivalent to cast(expr AS TIME).
If fmt is malformed, Azure Databricks raises INVALID_DATETIME_PATTERN. If expr cannot be parsed using fmt, Azure Databricks raises CANNOT_PARSE_TIME.
To return NULL instead of an error in case of a malformed expr use try_to_time.
Common error conditions
Examples
> SELECT to_time('10:30:00');
10:30:00
> SELECT to_time('10:30:00', 'HH:mm:ss');
10:30:00
> SELECT to_time('10.30.00', 'HH.mm.ss');
10:30:00
> SELECT to_time('not-a-time');
Error: CAST_INVALID_INPUT