What difference between NOW()
, SYSDATE()
, CURRENT_DATE()
in MySQL and where it can be used in real scenario .
I tried NOW()
,SYSDATE()
,Current_Date()
when I insert data into a table and column datatype is TIMESTAMP
all are given same date and time.
NOW() returns a constant time that indicate's the time at which the statement began to exicute whereas SYSDATE () returns the time at which it exicute... OR in other words NOW ()shows query exicution time and SYSDATE() shows self exicution time..
MySQL NOW() Function The NOW() function returns the current date and time. Note: The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or as YYYYMMDDHHMMSS. uuuuuu (numeric).
1 Answer. CURDATE() returns the current date whereas DATE() extracts the date part or datetime expression.
The NOW() function gives current datetime as a timestamp while CURDATE() gives only current date, not time.
Current_date() will only give you the date.
now() give you the datetime when the statement,procedure etc... started.
sysdate() give you the current datetime.
Look at the seconds after waiting 5 seconds between now()1 sysdate()1 with the following query (scroll to the right):
select now(),sysdate(),current_date(),sleep(5),now(),sysdate(); -- will give -- now() sysdate() current_date() sleep(5) now()1 sysdate()1 -- 6/10/2014 2:50:04 AM 6/10/2014 2:50:04 AM 6/10/2014 12:00:00 AM 0 6/10/2014 2:50:04 AM 6/10/2014 2:50:09 AM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With