NOW()¶
Function description¶
The NOW() function returns the value in the ‘YYY-MM-DD HH:MM:SS’ format of the current date and time.
NOW() returns the time when the statement starts execution. This is different from the behavior of SYSDATE(), which returns dynamic real-time time during execution.
Function Syntax¶
Text
> NOW(fsp)
Parameter definition¶
Parameters |
Description |
|---|---|
fsp |
Non-essential parameters. If the fsp parameter is given to specify a fractional second accuracy from 0 to 6, the return value includes the fractional second portion of the number. |
Example¶
Text
mysql> select now();
+----------------------------+
| now() |
+----------------------------+
| 2024-04-29 08:03:50.479238 |
+----------------------------+
1 row in set (0.03 sec)
mysql> select now(6);
+----------------------------+
| now(6) |
+----------------------------+
| 2024-04-29 08:05:26.528629 |
+----------------------------+
1 row in set (0.02 sec)
mysql> SELECT NOW(), SLEEP(2), NOW();
+----------------------------+----------+----------------------------+
| now() | sleep(2) | now() |
+----------------------------+----------+----------------------------+
| 2024-04-29 08:17:23.876546 | 0 | 2024-04-29 08:17:23.876546 |
+----------------------------+----------+----------------------------+
1 row in set (2.06 sec)
mysql> SELECT SYSDATE(), SLEEP(2), SYSDATE();
+----------------------------+----------+----------------------------+
| sysdate() | sleep(2) | sysdate() |
+----------------------------+----------+----------------------------+
| 2024-04-29 16:19:21.439725 | 0 | 2024-04-29 16:19:23.440187 |
+----------------------------+----------+----------------------------+
1 row in set (2.01 sec)
Last updated on