- Categories:
Context functions (General)
LOCALTIME¶
Returns the current time for the system.
ANSI-compliant alias for CURRENT_TIME.
Syntax¶
LOCALTIME()
LOCALTIME
Arguments¶
None.
Returns¶
Returns a value of type TIME.
Usage notes¶
The setting of the TIMEZONE parameter affects the return value. The returned time is in the time zone for the session.
The display format for times in the output is determined by the TIME_OUTPUT_FORMAT session parameter (default
HH24:MI:SS
).To comply with the ANSI standard, this function can be called without parentheses in SQL statements.
However, if you are setting a Snowflake Scripting variable to an expression that calls the function (for example,
my_var := <function_name>();
), you must include the parentheses. For more information, see the usage notes for context functions.Do not use the returned value for precise time ordering between concurrent queries (processed by the same virtual warehouse) because the queries might be serviced by different compute resources (in the warehouse).
Examples¶
Show the current local time and local timestamp:
SELECT LOCALTIME(), LOCALTIMESTAMP();
+-------------+-------------------------------+
| LOCALTIME() | LOCALTIMESTAMP() |
|-------------+-------------------------------|
| 15:32:45 | 2024-04-17 15:32:45.775 -0700 |
+-------------+-------------------------------+