SQL NOW Vs SYSDATE Datatype

The current timestamp values are returned by MySQL's NOW() and SYSDATE() methods.

However, the output of each of them is affected by the execution time. This makes a significant distinction between them.


SQL NOW Datatype

NOW() returns a constant time that indicates when the statement started running.

This is in contrast to the behaviour of SYSDATE ().

Example: To show how the return value might differ depending on the function used.

Select NOW(), AS 'Current date and time';

Output: The output will be

Current date and time
21-04-2022 12:35:09

SQL SYSDATE Datatype

SYSDATE () returns the precise time of execution.

Example: Here's an example of how the return value varies based on the function you're using.

SELECT SYSDATE(), SLEEP(10) AS '', SYSDATE();

Output: The output of system which has sleep 10sec

sysdate() Column1 sysdate()1
21-04-2022 12:37:56 0 21-04-2022 12:38:06

Example 2: SYSDATE function

Select SYSDATE(), SLEEP(5), SYSDATE();

In comparison, the above query demonstrates that the SYSDATE() function returns the time at which it executes because it returns a value that is really incremented by 5 seconds after 5 seconds of system sleep.

Output: The output of above query is

sysdate() sleep(5) sysdate()1
21-04-2022 12:41:13 0 21-04-2022 12:41:18

SQL Difference Between NOW AND SYSDATE Statement

In below table we discuss the main contrasts in now vs sysdate fuction:-

NOW SYSDATE
NOW() returns a constant time that represents the start of the statement's execution. Because NOW() is derived from the mysql variable "TIMESTAMP," which is established when the statement is executed, it will not change throughout the statement's execution. SYSDATE() returns the current time of execution.
The value returned by NOW() is affected by the SET TIMESTAMP command, but not by SYSDATE (). The SET TIMESTAMP statement has no effect on the SYSDATE value ().
NOW() returns a constant time that represents the start of the statement's execution. SYSDATE() returns the precise time of execution.
NOW() will only be evaluated once, at the beginning of the query execution. Within the same sentence, SYSDATE() is evaluated every time.