Extract clock time from a date and time value

How to pull the time of day out of a date and time value, what each method really changes, and when the result stays usable after copying or sharing.

Pulling the clock time out of a combined date and time value sounds like one operation, but there are two different jobs hiding under it. One changes how the value looks. The other produces a new value that holds only the time. Which one you need depends on what happens to the result next: whether it gets calculated, sorted, pasted into another program or read by a person. This review covers how each approach works, what it preserves and where it tends to break.

Is extracting the time suitable for your use?

In most cases, extract the time as a real time value rather than as text. A real time value can still be added, compared, sorted and reformatted later. Its main benefit is that it keeps the time usable for calculation. Its main cost is that it displays correctly only where the destination understands the value type and applies a sensible format.

Plain text, such as the characters 14:30 or 2:30 PM, is the better choice when the result leaves the spreadsheet or database. Examples include an email, a report, a label, a CSV file for a system with unknown parsing rules, or anything a person reads but nobody calculates with. Text looks the same everywhere it is pasted. In exchange, it loses its numeric meaning and can sort or compare incorrectly.

Do not extract the time at all if you only want the sheet to show the time. Changing the cell's display format hides the date without removing it, so nothing is lost.

What the transformation actually changes

The word extract covers three different mechanisms, and confusing them causes most problems.

  • Display formatting only: the stored value is unchanged, the date is still there, and only what you see on screen differs.
  • Numeric extraction: a new value is created that keeps the time portion and discards the date. It remains a number or time type.
  • Text conversion: the time is rendered as a string of characters. The result is no longer a time to the software, only text that looks like one.

In common spreadsheet programs such as Excel and Google Sheets, a date and time is stored as a serial number. The whole-number part counts days and the fractional part represents the share of the day that has passed, so 0.5 is noon. Removing the whole-number part therefore leaves only the time of day.

Spreadsheet formulas

Each formula below assumes the date and time value is in cell A1.

=MOD(A1,1)                              numeric time; format the cell as time
=A1-INT(A1)                             same result for positive dates
=TIME(HOUR(A1),MINUTE(A1),SECOND(A1))   rebuilds a clean time value
=TEXT(A1,"hh:mm:ss")                    text, 24-hour
=TEXT(A1,"h:mm AM/PM")                  text, 12-hour

The first three formulas return numbers. The result can look like a long decimal until you apply a time format to the cell, which is expected behavior and not an error.

MOD and subtraction work on floating-point values, so in rare cases they can leave a tiny rounding remainder that affects exact equality checks. The TIME version rebuilds the value from whole hours, minutes and seconds. That avoids the remainder, but it also drops any fractions of a second.

TEXT returns a string. Its format codes can depend on the spreadsheet's language and locale settings, so a formula written in one regional setup may not behave the same way in another. Check the codes in your own environment.

Code and databases

# Python
from datetime import datetime
dt = datetime(2026, 10, 31, 14, 30, 15)
dt.time()                # time object: 14:30:15
dt.strftime("%H:%M:%S")  # text: '14:30:15'
dt.strftime("%I:%M %p")  # text: '02:30 PM'

The example input is 31 October 2026 at 14:30:15. The time object keeps that as a time. The two strftime calls produce text in 24-hour and 12-hour form.

In SQL, casting a datetime column to a time type is common, but the exact syntax and the precision kept vary by database. Check your dialect's documentation rather than assuming one form works everywhere.

Source values that are really text

If the source looks like a date and time but is stored as text, numeric methods will fail or return errors. This often happens with imported data such as 2026-10-31T14:30:15. The value must first be parsed into a real date and time, or the time portion must be cut out as a substring. Cutting a substring is quick, but it gives text and depends on every row using exactly the same layout.

Time zones

Extraction returns the clock time as stored. If the original value is in UTC or in another zone, the extracted time is the clock time in that zone, not the reader's local time. Spreadsheet serial numbers carry no time zone information at all. Convert the time zone before extracting, not after. Note that a conversion can also move the date, which is easy to miss once the date has been removed.

Will the result stay readable and usable after copying or sharing?

The two result types behave differently once they leave their original location.

  • Numeric time values: pasted as values into another sheet, they may appear as a bare decimal until a time format is applied. Exported to CSV, they are written however the cell was displayed, or as the underlying number, depending on the program and export settings.
  • Text times: they paste predictably, but they cannot be summed or averaged. They also sort as characters, so 10:00 AM can land before 9:00 AM in a 12-hour list.
  • Editing: changing a text time means retyping it, while a numeric time can be adjusted by calculation.

Ambiguity is the main readability risk. A time without a date, a time zone or an AM/PM marker can be misread. For example, 02:30 could mean early morning or, to someone expecting 12-hour notation, afternoon. When the time goes to people, include AM/PM or use 24-hour notation consistently. Add the time zone whenever readers may be in different zones.

How screen readers and other assistive technology announce a numeric time cell compared with a text string such as 14:30 was not tested for this review, and no documentation for specific products was supplied. Behavior may differ by product and settings. If accessibility matters for your output, test with the assistive technology your readers actually use, and consider writing times in an unambiguous form.

Search and filtering follow the same split as the data types. Text times match text searches. Numeric times respond to range filters such as between 9:00 and 17:00. Pick the type that suits how the data will be queried.

When you need a plain-text version

Keep the numeric time as your working value, and produce a plain-text copy whenever the time is published, sent to a system whose import rules you do not control, or read by people in different regions. Keeping both avoids choosing between calculation and portability.

Gaps in this review

No tool-specific evidence was available. This review does not cover the behavior of particular online time-extraction tools, the export settings of particular programs, the parsing rules of particular destination systems, or how specific assistive technologies announce times. The formulas and mechanisms above reflect generally documented spreadsheet and programming behavior. Confirm the details in the software version and locale you use.