11 Vote

MySQL: Difference between NOW() and CURDATE()

Question by Compi | Last update on 2024-04-08 | Created on 2016-04-25

In order to get or determine the current date, MySQL is providing the functions NOW() and CURDATE(). You can use this functions for example if you want to compare some column value with the recent date.

However, I am interested in the difference between those functions. In which case should I use which one of those functions and why are there actually two functions for returning the same value in MySQL?

ReplyPositiveNegative
2Best Answer2 Votes

Indeed, both functions relate to the current date. However, the returned values are nevertheless not the same - so the functions are different even if you do not notice this in some cases. For the sake of completeness, I have added the function CURTIME() to the overview.

  • CURDATE() is providing the current date without time, for example 2024-01-01.
  • CURTIME() is providing the current time without date, for example 20:00:00.
  • NOW() is providing the current date as well as the current time, for example 2024-01-01 20:00:00.

So, there is the following relationship:

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

Which function is appropriate for which purpose depends on whether you only need the date, only the time or both of them.
Last update on 2024-04-08 | Created on 2016-04-26

ReplyPositive Negative
Reply

Related Topics

Android Getting Sound Levels

Open Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.