The function retrieves the current system time and returns it as a datetime value (DATETIME). An optional precision can be specified to adjust the number of digits in the fractional seconds part of the return value.
LOCALTIME([<precision>]) LOCALTIMESTAMP([<precision>]))
| Parameter | Description |
|---|---|
<precision> | Optional parameter specifying the precision of the fractional seconds part in the return value. The range is 0 to 6, and the default is 0 (no fractional seconds). Limited by the JDK implementation: if FE is built with JDK8, the precision supports up to milliseconds (3 fractional digits), and higher precision digits will be filled with 0. If higher precision is required, please use JDK11. |
<precision> is out of range (e.g., negative or greater than 6), the function will return an error.select LOCALTIME(),LOCALTIME(3),LOCALTIME(6);
+---------------------+-------------------------+----------------------------+ | now() | now(3) | now(6) | +---------------------+-------------------------+----------------------------+ | 2025-01-23 11:50:18 | 2025-01-23 11:50:18.883 | 2025-01-23 11:50:18.883000 | +---------------------+-------------------------+----------------------------+