MySQL: Curdate() vs Now()
Asked Answered
J

4

88

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

Jacky answered 9/12, 2010 at 11:36 Comment(0)
I
119

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

Illusive answered 9/12, 2010 at 11:38 Comment(0)
E
86

Just for the fun of it:

CURDATE() = DATE(NOW())

Or

NOW() = CONCAT(CURDATE(), ' ', CURTIME())
Exemplary answered 27/7, 2012 at 14:33 Comment(0)
O
46

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
Obsession answered 9/12, 2010 at 11:44 Comment(0)
B
2

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 ;

Bolanos answered 14/9, 2017 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.