MySQL: Curdate () vs Now ()

What is the difference between MySQL Curdate() and Now() ?

+60
sql mysql datetime
Dec 09 '10 at 11:36
source share
4 answers

For such questions, you should always take a look at the manual first. Date and time functions in the mySQL manual

CURDATE() returns the DATE part of the current time. CURDATE () Guide

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

+88
Dec 09 '10 at 11:38
source share
— -

Just for fun:

 CURDATE() = DATE(NOW()) 

or

 NOW() = CONCAT(CURDATE(), ' ', CURTIME()) 
+61
Jul 27 '12 at 2:33 pm
source share

CURDATE() will give the current date, and NOW() will give the full time.

Run the queries and you will find out what is the difference between them.

 SELECT NOW(); -- You will get 2010-12-09 17:10:18 SELECT CURDATE(); -- You will get 2010-12-09 
+26
Dec 09 '10 at 11:44
source share

In fact, MySQL provides many convenient functions in everyday life without any effort on the part of the user -

NOW () it creates the date and time as in the current script, whereas CURDATE () is only the release date, CURTIME () , we can use one of them according to our need with CAST or merge others to calculate it, MySQL is rich in these types of functions .

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

+1
Sep 14 '17 at 9:48 on
source share



All Articles