Categories:
Context Functions (General)

CURRENT_TIME

Returns the current time for the system.

Aliases:
LOCALTIME

Syntax

CURRENT_TIME( [ <fract_sec_precision> ] )

CURRENT_TIME

Arguments

fract_sec_precision

This optional argument indicates the precision with which to report the time. For example, a value of 3 says to use 3 digits after the decimal point – i.e. to specify the time with a precision of milliseconds.

The default precision is 9 (nanoseconds).

Valid values range from 0 - 9. However, most platforms do not support true nanosecond precision; the precision that you get might be less than the precision you specify. In practice, precision is usually approximately milliseconds (3 digits) at most.

Note

  • Fractional seconds are only displayed if they have been explicitly set in the TIME_OUTPUT_FORMAT parameter for the session, e.g. 'HH24:MI:SS.FF'.

Returns

Returns a value of type TIME.

Usage Notes

  • To comply with ANSI standards, this function can be called without parentheses.
  • 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 servers (in the warehouse).

Examples

Set the time output format to HH24:MI:SS.FF, then return the current time with fractional seconds precision first set to 2, then 4, and then the default (9):

ALTER SESSION SET TIME_OUTPUT_FORMAT = 'HH24:MI:SS.FF';

SELECT CURRENT_TIME(2);

+-----------------+
| CURRENT_TIME(2) |
|-----------------|
| 22:33:24.49     |
+-----------------+

SELECT CURRENT_TIME(4);

+-----------------+
| CURRENT_TIME(4) |
|-----------------|
| 22:33:26.2610   |
+-----------------+

SELECT CURRENT_TIME;

+--------------------+
| CURRENT_TIME       |
|--------------------|
| 22:33:28.263000000 |
+--------------------+