- Instant help with your Sql coding problems

Get current date in MySQL

Question:
How to get current date in MySQL?
Answer:
SELECT id, deadline, CURDATE() AS 'currentDate' FROM task WHERE deadline > CURDATE();
Description:

In MySQL you can get the actual date, using the built-in CURDATE() function. CURDATE() returns the current date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context.

In other SQL code, you may also see the CURRENT_DATE() function, which is a synonym for CURDATE() . You can use both either in a WHERE condition or as a selected column.

 

Reference:
CURRDATE reference
Share "How to get current date in MySQL?"