MySQL CURDATE() Function
MySQL CURDATE(): Retrieve Today's Date in Queries
The CURDATE() function returns the current date according to your MySQL session time zone. It requires no input parameters and outputs a DATE value formatted as 'YYYY-MM-DD' in string context.
Developers use CURDATE() to filter today's transactions, flag overdue invoices, and set dynamic report cutoffs.
Syntax
CURDATE() takes zero arguments and always requires empty parentheses:
CURDATE()
In numeric expressions such as CURDATE() + 0, MySQL returns an integer in YYYYMMDD format (for example, 20260512). Unlike CURTIME(), CURDATE() does not accept a fractional seconds argument.
Practical Example
Suppose you want a daily report from demo_orders showing every order placed today alongside its status.
SELECT
order_id,
customer_id,
order_date,
total_amount
FROM demo_orders
WHERE order_date = CURDATE();
| order_id | customer_id | order_date | total_amount |
|---|---|---|---|
| 204 | 18 | 2026-05-12 | 149.50 |
| 205 | 33 | 2026-05-12 | 89.00 |
If order_date is stored as a DATETIME instead of a DATE, order_date = CURDATE() only matches midnight (00:00:00). For DATETIME columns, filter with order_date >= CURDATE() AND order_date < CURDATE() + INTERVAL 1 DAY.
Common Mistakes & NULL Behavior
Keep these rules in mind when using CURDATE() in production SQL:
- No input means no
NULLfailure: BecauseCURDATE()accepts no required columns or arguments,NULLvalues in your table never causeCURDATE()itself to returnNULL. - Passing arguments raises a syntax error: Writing
CURDATE(6)orCURDATE(order_date)is invalid SQL in MySQL. - Omitting parentheses fails: Unlike the SQL standard keyword
CURRENT_DATE, writingCURDATEwithout()throws an unknown column error. - Session time zone dependency:
CURDATE()reflects@@session.time_zone, not necessarily the client machine's local clock.
Frequently Asked Questions
What is the difference between CURDATE() and CURRENT_DATE()?
They are functionally identical in MySQL. CURDATE() is MySQL's shorter alias and requires parentheses, while CURRENT_DATE works both with and without ().
Why does WHERE created_at = CURDATE() miss orders from today?
If created_at is a DATETIME column, MySQL promotes CURDATE() to 'YYYY-MM-DD 00:00:00'. Orders placed at 10:15:00 will not equal midnight, so use a half-open range query instead.
Can I use CURDATE() as a column DEFAULT value?
In MySQL 8.0.13 and later, you can set an expression default like DEFAULT (CURDATE()) with parentheses on DATE columns, though older MySQL 5.7 versions reject it.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Try it Yourself
Experiment with the code from this lesson in our interactive playground.