Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: Curdate() vs Now()

People also ask

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 output displayed by NOW () and Curdate () function?

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

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

The Difference Between SYSDATE() and NOW() SYSDATE() returns the time at which it executes. NOW() returns a constant time that indicates the time at which the statement began to execute. The SET TIMESTAMP statement affects the value returned by NOW() but not by SYSDATE() .

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


For questions like this, it is always worth taking a look in the manual first. Date and time functions in the mySQL manual

CURDATE() returns the DATE part of the current time. Manual on CURDATE()

NOW() returns the date and time portions as a timestamp in various formats, depending on how it was requested. Manual on NOW().


Just for the fun of it:

CURDATE() = DATE(NOW())

Or

NOW() = CONCAT(CURDATE(), ' ', CURTIME())

CURDATE() will give current date while NOW() will give full date time.

Run the queries, and you will find out whats the difference between them.

SELECT NOW();     -- You will get 2010-12-09 17:10:18
SELECT CURDATE(); -- You will get 2010-12-09

Actually MySQL provide a lot of easy to use function in daily life without more effort from user side-

NOW() it produce date and time both in current scenario whereas CURDATE() produce date only, CURTIME() display time only, we can use one of them according to our need with CAST or merge other calculation it, MySQL rich in these type of function.

NOTE:- You can see the difference using query select NOW() as NOWDATETIME, CURDATE() as NOWDATE, CURTIME() as NOWTIME ;