This article mainly introduces the relevant information about the detailed explanation of the MySQL curdate() function. I hope this article can help everyone understand how to use MysqL curdate(). Friends in need can refer to it
MySQL CURDATE function introduction
If you use the string context or YYYMMDD format in a numeric context, the CURDATE() function will return the current date as a value in the "YYYY-MM-DD" format.
The following example shows how to use the CURDATE() function in a string context.
sql> SELECT CURDATE(); +------------+ | CURDATE() | +------------+ | 2017-08-10 | +------------+ 1 row in set (0.00 sec)
The following examples illustrate how the CURDATE() function can be used in a numeric context:
##
mysql> SELECT CURDATE() + 0; +---------------+ | CURDATE() + 0 | +---------------+ | 20170810 | +---------------+ 1 row in setCURRENT_DATE and CURRENT_DATE( ) is a synonym for CURDATE().
mysql> SELECT CURRENT_DATE(), CURRENT_DATE, CURDATE(); +----------------+--------------+------------+ | CURRENT_DATE() | CURRENT_DATE | CURDATE() | +----------------+--------------+------------+ | 2017-08-10 | 2017-08-10 | 2017-08-10 | +----------------+--------------+------------+ 1 row in set
CURDATE and NOW functions
The CURDATE() function only returns the current date, while the NOW() function returns the current time Date and time part. The result of the CURDATE() function is equivalent to the following expression:mysql> SELECT DATE(NOW()); +-------------+ | DATE(NOW()) | +-------------+ | 2017-08-10 | +-------------+ 1 row in setIn this tutorial, you learned how to use the MySQL CURDATE() function to get the current date value.
The above is the detailed content of Code example of curdate() function in MySQL. For more information, please follow other related articles on the PHP Chinese website!