Lesson

MySQL CURTIME() Function

10 min reading
Free Course

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 from 0 to 6. Defaults to 0 whole 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 NULL table columns: CURTIME() takes no mandatory inputs, so NULL values in other fields never make CURTIME() evaluate to NULL.
  • Parentheses are mandatory: Writing SELECT CURTIME; without () triggers an unknown column error in MySQL.
  • Invalid fsp values fail at parse time: Passing CURTIME(-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 at 02:00:00 when the current time is 23:00:00. Use full DATETIME columns 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.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
MySQL Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum