Knowledge base / SQL

CURRENT_TIME in SQL: time of day, zones and overnight filters

A time alone cannot select today's events. I separate time of day from timestamps and explain overnight boundaries and engine differences.

Kajo RudzińskiPublished Updated 4 min read

An unnumbered clock dial and blank calendar connected by paths in yellow and navy pixel art.

CURRENT_TIME provides a time of day in engines that support it. I first decide whether the task needs a time alone or a complete event timestamp. Two o’clock occurs every day. It cannot tell you whether an order was created today, yesterday or a month ago. That distinction determines whether many apparently simple filters answer the intended question.

Availability and result type

Environment Expression Meaning
PostgreSQL 18 SELECT CURRENT_TIME; Time with time zone at transaction start
PostgreSQL 18 SELECT LOCALTIME; Time without time zone, also at transaction start
MySQL 8.4 SELECT CURRENT_TIME; Synonym of CURTIME(), using the session zone
SQLite SELECT CURRENT_TIME; UTC time text
SQL Server SELECT CAST(SYSDATETIME() AS time); Conversion-based alternative; no CURRENT_TIME function
Oracle 19c SELECT CURRENT_TIMESTAMP FROM DUAL; Full timestamp with time zone; no CURRENT_TIME function

See PostgreSQL, MySQL, SQLite, SQL Server and Oracle. The Oracle alternative deliberately retains the date. Formatting it as a time-only string serves presentation rather than creating a native time-type equivalent.

I would not describe every engine’s output as one HH:MM:SS format. Fractional seconds or an offset can be present. PostgreSQL CURRENT_TIME(3) limits fractional precision to three digits; MySQL also supports CURRENT_TIME(3). More displayed digits do not by themselves guarantee greater clock accuracy.

Today’s planned events after the current time

Consider a synthetic MySQL 8.4 appointment calendar with appointment_date of type DATE and appointment_time of type TIME. Assume local time consistent with the session zone and ordinary unambiguous hours, outside daylight-saving transitions. Selecting today’s later appointments requires both conditions:

SELECT id, appointment_date, appointment_time
FROM appointments
WHERE appointment_date = CURRENT_DATE
  AND appointment_time > CURRENT_TIME;

Suppose today is 15 November 2026 and the current time is 14:00. Today’s 15:00 appointment passes; today’s 13:00 appointment does not. Yesterday’s 15:00 appointment also fails because of the date condition. Exactly 14:00 today is excluded by the strict greater-than comparison. Changing it to greater-than-or-equal changes that boundary and should reflect an explicit rule.

A filter on appointment_time alone considers times across every date. It should not be described as selecting records created today. For a record of actual operations, I would usually keep a complete timestamp. Separate date and time fields can serve a simple schedule, but their combined meaning still needs a definition.

PostgreSQL uses the transaction’s clock

In PostgreSQL, CURRENT_TIME and LOCALTIME refer to transaction start. A second call several seconds later in the same transaction need not show a later time. This matters for long-running work and interpreting event sequences. I would not present this function as a stopwatch measuring the duration of successive processing stages.

For a time without time zone column, LOCALTIME may suit a local-time comparison when the session zone is explicit. Avoid casually mixing time values with and without zones. For actual event moments, preserve the date and choose an appropriate timestamp type. A time plus offset still does not describe the calendar needed to interpret changing time-zone rules.

An overnight shift crosses midnight

For a MySQL 8.4 schedule covering 22:00 inclusively to 06:00 exclusively, the condition covers two portions of the day:

SELECT id, appointment_time
FROM appointments
WHERE appointment_time >= '22:00:00'
   OR appointment_time < '06:00:00';

23:00 and 02:00 pass; 12:00 does not. BETWEEN with 22:00 as the lower endpoint and 06:00 as the upper endpoint does not express a wrap around midnight. This filter describes a recurring time of day independently of date. For a particular shift starting on 15 November, use a complete interval from 15 November at 22:00 to 16 November at 06:00.

A time dial connects the two portions of an overnight interval around midnight.

Store the moment and format the display later

A time alone is usually insufficient for later log analysis. At 00:05, an event at 23:55 on the preceding day is earlier, even though comparing the hours alone suggests the opposite. Preserve the date and an agreed time-zone interpretation. Appending today’s date to every old time value cannot recover the day that was discarded at collection.

In SQL Server, CAST(SYSDATETIME() AS time) removes the date from its source value. SYSDATETIME returns datetime2(7) without a time-zone offset. The conversion can support a time-only display, but it carries neither the date nor the zone. Name and document the result accordingly.

A small exercise before a larger report

Write down 00:00, 05:59, 06:00, 12:00, 22:00 and 23:00. For the overnight schedule above, 00:00, 05:59, 22:00 and 23:00 pass. Give those records different dates, then explain what changes when the question concerns one particular night. This separates a recurring timetable from the chronology of actual events.

Read CURRENT_DATE and WHERE filtering next. Before publishing a time filter, I state the engine, column type, zone and boundaries. Those four details are more useful than an assurance that the function simply shows the current time.

Key takeaways

Is CURRENT_TIME available in SQL Server?

No. CAST(SYSDATETIME() AS time) can produce a time-only value. This converts a full date-time value rather than calling a CURRENT_TIME function.

Does a time-only filter select today's records?

No. Include a date condition or a complete timestamp range. The same time of day occurs on many dates.

Does PostgreSQL CURRENT_TIME advance during a transaction?

It refers to transaction start and remains constant within that transaction. Do not treat it as an advancing wall-clock reading for measuring elapsed time.

AI was used in an automated way while working on this article. If you want to learn how to do it too, check out this project.

Kajo Rudziński

Newsletter KajoData

Let’s keep in touch.

I write about data analysis, learning and changing careers. My newsletter and the sign-up form are in Polish. If that works for you, I’d be glad to see you there.