Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between NOW(), SYSDATE() & CURRENT_DATE() in MySQL

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.

like image 472
Ashutosh SIngh Avatar asked Jun 10 '14 09:06

Ashutosh SIngh


People also ask

What is the difference between Sysdate () and now () function?

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..

What is now () in MySQL?

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).

What is the difference between Curdate () and date () functions?

1 Answer. CURDATE() returns the current date whereas DATE() extracts the date part or datetime expression.

What is the difference between Curdate And now?

The NOW() function gives current datetime as a timestamp while CURDATE() gives only current date, not time.


1 Answers

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 
like image 152
Benoit Avatar answered Oct 04 '22 13:10

Benoit