MySQL CURTIME() Function
MySQL CURTIME(): Read the Current Time of Day
The CURTIME() function returns the current time in your session time zone, omitting the calendar date. It works identically to CURRENT_TIME() and supports optional fractional seconds up to microsecond resolution.
Point-of-sale tools and shift monitors use CURTIME() to compare live clock times against store opening hours or cutoffs.
Syntax
Unlike CURRENT_TIME, CURTIME() always requires parentheses:
CURTIME()
CURTIME(fsp)
fsp: Optional precision literal from0to6. Defaults to0whole seconds.
In string context, it produces 'HH:MM:SS' (or 'HH:MM:SS.ffffff'). In numeric context (CURTIME() + 0), it outputs HHMMSS.
Practical Example
Suppose a dispatch desk checks demo_employees to find active couriers whose scheduled shift_end_time is still ahead of CURTIME().
SELECT
employee_id,
full_name,
shift_end_time,
CURTIME(2) AS query_time
FROM demo_employees
WHERE shift_end_time > CURTIME();
| employee_id | full_name | shift_end_time | query_time |
|---|---|---|---|
| 31 | Omar Faruk | 18:00:00 | 15:12:40.75 |
| 32 | Hannah Brooks | 20:30:00 | 15:12:40.75 |
Notice that CURTIME(2) formats two digits after the decimal point for hundredths of a second.
Common Mistakes & NULL Behavior
Avoid these mistakes when working with CURTIME():
- Safe around
NULLtable columns:CURTIME()takes no mandatory inputs, soNULLvalues in other fields never makeCURTIME()evaluate toNULL. - Parentheses are mandatory: Writing
SELECT CURTIME;without()triggers an unknown column error in MySQL. - Invalid
fspvalues fail at parse time: PassingCURTIME(-1),CURTIME(7), or a non-literal expression produces a syntax error. - Midnight rollover surprises: Comparing
shift_end_time > CURTIME()fails for overnight shifts ending at02:00:00when the current time is23:00:00. Use fullDATETIMEcolumns for overnight schedules.
Frequently Asked Questions
What is the difference between CURTIME() and NOW()?
CURTIME() returns only the clock time (HH:MM:SS), whereas NOW() returns both date and time (YYYY-MM-DD HH:MM:SS).
Does CURTIME() update for every row in a large UPDATE statement?
No. MySQL captures the statement start time once, so CURTIME() stays identical across every row updated by the same statement.
How can I convert CURTIME() into total seconds?
Wrap it inside TIME_TO_SEC(CURTIME()) to get the integer number of seconds elapsed since midnight.
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.