← Back to MySQL Course | Chapter 13: Date & Numeric Functions | Lesson 3 of 6

NOW CURDATE CURTIME

NOW, CURDATE and CURTIME are like asking a clock and a calendar: the date and time together, only today's date, or only the time.
Syntax
sql
NOW()
CURDATE()
CURTIME()

The Current Date and Time with NOW

NOW returns both the current date and time together as a single value, down to the second, making it the go-to function for timestamping exactly when a row was inserted or an event occurred.

Example: The Current Date and Time with NOW

sql
SELECT NOW() AS current_datetime;

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

The Current Date with CURDATE

CURDATE returns only today's date with no time component at all, which is the right choice when you care about which day something happened but the exact hour or minute is irrelevant, like a billing date.

Example: The Current Date with CURDATE

sql
SELECT CURDATE() AS today;

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

The Current Time with CURTIME

CURTIME returns only the current time with no date attached, useful for logging things like daily opening/closing hours or comparing against a recurring daily schedule rather than a specific calendar day.

Example: The Current Time with CURTIME

sql
SELECT CURTIME() AS right_now;

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

Saving Current Dates to Tables

These functions are commonly wired up as default column values, so MySQL automatically stamps new rows with the moment they were created without the application needing to calculate and send a timestamp itself.

Example: Saving Current Dates to Tables

sql
CREATE TABLE logs (id INT, message TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP);
INSERT INTO logs (id, message) VALUES (1, 'User signed up');
SELECT * FROM logs;

Simple Date Math with Intervals

You can add or subtract intervals directly against the current date, such as CURDATE() + INTERVAL 7 DAY, to compute things like a one-week deadline or trial expiration without manual date arithmetic in application code.

Example: Simple Date Math with Intervals

sql
SELECT CURDATE() + INTERVAL 7 DAY AS trial_expires;

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Using NOW() when only the date is needed, so comparisons with a DATE column fail on the time part.
  2. Assuming NOW() changes during a query, when it is fixed at the statement start (use SYSDATE() for the real time).
  3. Forgetting the time zone of the server when the output differs from your local time.
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.