Movatterモバイル変換


[0]ホーム

URL:


Categories:

Semi-structured and structured data functions (Cast)

AS_TIME

Casts aVARIANT value to aTIME value. This function doesnot convert values ofother data types, including timestamps, to TIME values.

See also:

AS_<object_type>

AS_DATE ,AS_TIMESTAMP_*

Syntax

AS_TIME(<variant_expr>)
Copy

Arguments

variant_expr

An expression that evaluates to a value of type VARIANT.

Returns

The function returns a value of type TIME or NULL:

  • If the type of the value in thevariant_expr argument is TIME, the function returns a value of type TIME.

  • If the type of the value in thevariant_expr argument doesn’t match the type of the outputvalue, the function returns NULL.

  • If thevariant_expr argument is NULL, the function returns NULL.

Examples

Create a table and load data into it:

CREATEORREPLACETABLEas_time_example(time1VARIANT);INSERTINTOas_time_example(time1)SELECTTO_VARIANT(TO_TIME('12:34:56'));
Copy

Use the AS_TIME function in a query to cast a VARIANT value to a TIME value:

SELECTAS_TIME(time1)AStime_valueFROMas_time_example;
Copy
+------------+| TIME_VALUE ||------------|| 12:34:56   |+------------+
Language:English

[8]ページ先頭

©2009-2025 Movatter.jp