CURRENT_DATE (or CURDATE) returns the server’s current date as a DATE value without the time part.
Grab today’s date directly from the server clock, ensuring every user and application sees the same value at query time. Ideal for audit columns, daily reports, and time-based filters.
Run SELECT CURRENT_DATE;
or the function form SELECT CURRENT_DATE();
.Both return YYYY-MM-DD
.
Combine CURRENT_DATE with a WHERE clause:SELECT * FROM Orders WHERE order_date = CURRENT_DATE;
This lists purchases placed since midnight.
Use DATE_SUB to define the range:SELECT * FROM Customers WHERE created_at BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE;
Wrap the function with DATE_FORMAT:SELECT DATE_FORMAT(CURRENT_DATE, '%M %d, %Y') AS pretty_date;
→ June 05, 2024
.
Let MySQL handle it: INSERT INTO Orders (customer_id, order_date, total_amount) VALUES (9, CURRENT_DATE, 149.00);
Store dates in UTC for global apps, test daylight-saving transitions, and avoid hard-coded literals in recurring jobs.
NOW() returns a DATETIME; implicit casts may hide time zones.Use CURRENT_DATE for pure dates.
Both CURRENT_DATE and CURDATE() work, but CURDATE
without ()
is invalid. Add parentheses or switch to CURRENT_DATE.
SELECT CURRENT_DATE;
provides a reliable, timezone-aware value for all date-only needs.
.
Yes. MySQL evaluates CURRENT_DATE using the current session’s time zone. Set SET time_zone
for consistent results.
No. Generated columns must be deterministic. Use a BEFORE INSERT/UPDATE trigger to populate the column with CURRENT_DATE.
Nothing—both return the same DATE value. CURRENT_DATE is ANSI-SQL, CURDATE() is MySQL-specific.