MySQL SYSDATE() Function
In MySQL, the SYSDATE()
function returns the current time and date in the YYYY-MM-DD hh:mm:ss
format.
Different from NOW()
, SYSDATE()
returns the exact system time of the function execution, while NOW()
returns a constant time that indicates the time at which the statement began to execute. (Within a stored function or trigger, NOW()
returns the time at which the function or triggering statement began to execute.)
SYSDATE()
Syntax
Here is the syntax of MySQL SYSDATE()
function:
SYSDATE()
SYSDATE()
Examples
Returns the current time of the system.
SELECT SYSDATE(), SYSDATE() + 1;
+---------------------+----------------+
| SYSDATE() | SYSDATE() + 1 |
+---------------------+----------------+
| 2022-04-12 03:34:13 | 20220412033414 |
+---------------------+----------------+
Note: The result of SYSDATE() + 0
is in YYYYMMDDhhmmss
format. SYSDATE() + N
means adding N
seconds to the current time.
The example below explains the difference between SYSDATE()
and NOW()
:
SELECT
NOW(),
SYSDATE(),
SLEEP(2),
NOW(),
SYSDATE()\G
NOW(): 2022-04-12 03:35:10
SYSDATE(): 2022-04-12 03:35:10
SLEEP(2): 0
NOW(): 2022-04-12 03:35:10
SYSDATE(): 2022-04-12 03:35:12