How to Extract Time From A Date And Time in Excel

Learn multiple Excel methods to extract time from a date-and-time value with step-by-step examples, troubleshooting tips, and real-world applications.

excelformulaspreadsheettutorial
12 min read • Last updated: 7/2/2025

How to Extract Time From A Date And Time in Excel

Why This Task Matters in Excel

When you collect transactional data, log files, GPS traces, machine readings, call-center records, or financial quotes, the timestamp is almost always stored as a single “date-and-time” value. While this all-in-one format is great for archiving, analysts often need to separate the components. Imagine a transportation company that records the exact moment a truck departs a depot. Operations managers want to chart departures by hour of day to optimize staffing, procurement wants to see mileage differences between morning and evening shifts, and finance wants to calculate overtime triggered by departures after 18:00. All of these tasks require isolating the time portion.

Retailers use point-of-sale exports containing full timestamps. By extracting time, they can identify peak shopping hours, plan shift rotations, and design targeted promotions. In manufacturing, production control systems write a date-time stamp for every unit produced. Engineers isolate the time to analyze machine performance across different shifts, detect anomalies during night runs, and forecast maintenance windows. In customer service, chat sessions are recorded with precise timestamps; isolating the time allows managers to correlate average handling times with staffing schedules.

Excel excels (pun intended) at this task because its serial date system stores dates as integers and times as fractions of a single day. That means the arithmetic to separate components is both fast and precise, avoiding string manipulation or database queries. If you try to treat timestamps as text, you risk inconsistencies, locale conflicts, and conversion errors. Mastering time extraction unlocks dynamic dashboards, pivot tables that slice by hour, conditional formats that highlight late arrivals, and formulas that compute turnaround times without manual cleanup. In short, knowing how to pull the time portion is foundational for any workflow that benchmarks performance, schedules resources, or uncovers temporal patterns in data.

Best Excel Approach

The most dependable way to extract the time from a date-and-time value is to strip away the integer (date) portion and keep only the fractional remainder, which represents the time of day. The MOD function does precisely that by returning the remainder after division. Because a full day equals 1 in Excel’s serial system, MOD(date_time,1) yields the desired fraction.

Key advantages of MOD:

  • It operates on the numeric date system, so it ignores regional date formats.
  • It returns a true time-serial number, not text, so you can use the result in further math (for example, subtracting two times to get a duration).
  • It is short, easy to remember, and volatility-free.
=MOD(A2,1)

Parameters
A2 – A cell containing a valid Excel date-and-time value.
1 – The divisor. Because 1 represents 24 hours, the remainder is always the fraction corresponding to the time.

When to use: Prefer MOD whenever you plan to perform additional calculations (elapsed hours, pivot-by-hour, conditional formatting).

Alternative quick methods include:

=A2-INT(A2)

Same logic as MOD, but subtracts the integer part. Another option:

=TIMEVALUE(TEXT(A2,"hh:mm:ss"))

Useful if the original data sometimes arrives as text; TIMEVALUE converts the string after TEXT formats it. However, this approach is slower and adds an extra conversion step, so treat it as a fallback.

Parameters and Inputs

To guarantee accurate results, your input must be a genuine Excel timestamp—essentially a number formatted as Date or Custom Date-Time. If the source column is text (left-aligned, fails in arithmetic), you must convert it first (for example, using DATEVALUE plus TIMEVALUE or Power Query).

Required input

  • A single cell reference or numeric value representing the date-and-time serial (e.g., 45123.59375, which equals 2023-07-14 14:15).

Optional considerations

  • Divisor in MOD. While we use 1, you could employ fractions for uncommon requirements (e.g., MOD(A2,1/24) to isolate minutes).
  • Custom number formats. After you calculate the time, you usually want to display it in a human-friendly way such as hh:mm AM/PM or [h]:mm for durations.

Data preparation

  • Remove blanks, errors, or mixed text using filters or IFERROR.
  • Ensure there are no negative timestamps (Excel rejects them).
  • If data comes from systems that deliver Unix epoch or ISO strings, transform them into Excel serial numbers first.

Edge cases

  • Midnight (00:00) returns zero. You might want to format such cells explicitly so they don’t appear empty.
  • Times recorded precisely at 24:00 roll into the next date; you must decide whether to coerce 24:00 back to 00:00 or leave it attached to the next day.

Step-by-Step Examples

Example 1: Basic Scenario

Suppose column A contains production timestamps:

A (Date-Time)
2023-11-02 08:30
2023-11-02 13:45
2023-11-02 18:15

Step 1 – Verify the data
Click a cell, look in the formula bar. You should see a serial number like 45234.35417. If you instead see the literal text “2023-11-02 08:30”, convert it with =VALUE(A2) or use Data ➜ Text to Columns with Date/MDY.

Step 2 – Insert the formula
In B2 enter:

=MOD(A2,1)

Step 3 – Apply time format
Select B2:B4 ➜ Ctrl+1 ➜ Custom ➜ hh:mm AM/PM.

Expected results:

  • 08:30 AM
  • 01:45 PM
  • 06:15 PM

Why it works
Each timestamp is a number like 45234.35417. The integer 45234 equals 02-Nov-2023. The fractional part .35417 represents .35417 × 24 = 8.5 hours. MOD keeps that fraction, and formatting shows it as time.

Common variations

  • If you need 24-hour format, select HH:MM.
  • For dashboards, you might round to the nearest hour with =MROUND(MOD(A2,1),"1:00").

Troubleshooting

  • If you get ##### symbols, the column is too narrow—widen it.
  • If you see bizarre dates like 0-Jan-1900, you forgot to change the number format to Time.

Example 2: Real-World Application

Scenario: A call-center exports every customer interaction in a CSV. Column B shows full timestamps. Management wants to build a pivot table to count calls by hour.

Data setup (simplified):

Call IDTimestampAgent
10012024-02-15 07:05:12A15
10022024-02-15 07:59:35A07
10032024-02-15 08:02:03A12
18952024-02-15 21:48:55A03

Step-by-step

  1. Import the CSV using Data ➜ From Text/CSV. Power Query automatically recognizes the timestamp column as Date/Time. Click “Load.”

  2. In the new table sheet, insert a column called “Time Only” in column D. Enter:

=MOD([@Timestamp],1)

Because structured references wrap the literal header, Excel will spill the formula down automatically.

  1. Change the Time Only column’s format to hh:mm.
    Result examples: 07:05, 07:59, 08:02, …, 21:48.

  2. Insert a helper column “Hour Bucket” in column E to group by hour:

=HOUR([@Time Only])
  1. Create a Pivot Table:
  • Rows → Hour Bucket
  • Values → Call ID (Count)
    Now you instantly see call volume spikes at 9, 13, and 18.

Business impact
Staffing can be adjusted so that more agents are logged in during peak hours. Quality assurance can audit outlier calls after 20:00. Finance can allocate overtime budgets more accurately.

Integration touches

  • Conditional formatting to color highlight hours with more than 120 calls.
  • Slicers tied to date to quickly compare weekdays vs weekends.

Performance for larger datasets
On 50,000 rows, MOD remains lightning fast because it is non-volatile and vectorized. Avoid TEXT for the calculation step because that forces repeated string conversions.

Example 3: Advanced Technique

Edge Case: IoT sensors log data every second, storing Unix epoch integers (seconds since 1-Jan-1970). You need the time of day in Excel for 2 million records and must account for daylight saving changes.

  1. Convert epoch to Excel serial with Power Query to offload processing:
    PQ formula in Add Column ➜ #datetime(1970,1,1,0,0,0) + #duration(0,0,0,[Epoch]).

  2. Load as Connection Only and add to Data Model to reduce memory.

  3. In DAX (Power Pivot) create a calculated column TimeOnly:

TimeOnly = MOD('Sensor Data'[DateTime],1)
  1. Because DAX lacks a native MOD for datetime, you can alternatively use:
TimeOnly = 'Sensor Data'[DateTime] - INT('Sensor Data'[DateTime])
  1. Build a pivot chart that plots average vibration per minute across 24 hours. Use a Time dimension table and relationship.

Performance optimization

  • Keep numeric data types; avoid converting to text inside DAX.
  • Use star schema to isolate Date dimension, enabling efficient slice operations.

Error handling

  • If an epoch converts to a date earlier than 1900, Excel returns an error; filter those out in Power Query.
  • Daylight saving transitions can duplicate times like 01:30 twice or skip them. Handle via a separate DST flag column.

Professional tips

  • When sharing with colleagues who only have standard Excel (no data model), push the cleaned table back to the sheet and use normal formulas; the MOD logic remains intact.
  • Document the time zone assumption in a metadata worksheet to prevent misinterpretation.

Tips and Best Practices

  1. Always store the extracted time as a number, not text, so it can participate in math.
  2. Format the result with a custom code like hh:mm;@ to keep leading zeros.
  3. Recalculate only when necessary. Because MOD is non-volatile, you can disable automatic calculation without breaking results.
  4. For dashboards, pre-bucket times (HOUR, MINUTE) in helper columns to avoid heavy grouping at pivot time.
  5. Use structured references in Excel Tables so formulas auto-fill as new rows arrive.
  6. Document the original time zone and daylight saving rules in the workbook properties or a hidden sheet.

Common Mistakes to Avoid

  1. Treating timestamps as text. This leads to failed arithmetic, mis-sorted columns, and pivot tables that aggregate strings alphabetically. Always convert to true dates first.
  2. Forgetting to apply a time format. The raw result (0.59375) confuses users and QA reviewers; apply hh:mm:ss.
  3. Mixing date systems (1900 vs 1904). Files from macOS Excel use the 1904 system—if you copy without conversion, extracted times can shift. Check File ➜ Options ➜ Advanced ➜ When Calculating.
  4. Ignoring midnight zeros. Excel displays 0 as 00:00 only if formatted; otherwise, you may think the cell is blank. Use a conditional format to shade zero times so they stand out.
  5. Using volatile functions like NOW() inside large datasets. If you combine NOW() with MOD, the sheet recalculates constantly. Instead, capture the current time once in a helper cell and reference it.

Alternative Methods

Below is a comparison of several approaches to extract time:

MethodFormula ExampleOutput TypeProsCons
MOD`=MOD(`A2,1)Numeric timeFast, non-volatile, regional-agnosticRequires formatting
Subtract INT=A2-INT(A2)Numeric timeSame advantages, easy to readSlightly longer
TEXT`=TEXT(`A2,\"hh:mm\")TextNo formatting step neededText cannot be used in math, slower
TIMEVALUE + TEXT`=TIMEVALUE(`TEXT(A2,\"hh:mm:ss\"))Numeric timeConverts text timestampsDouble conversion, volatile in old versions
Flash FillType first result then Ctrl+ETextNo formula maintenanceManual, breaks with new rows
Power Query Split ColumnTransform ➜ Time OnlyNumeric timeScales to millions of rows, data model integrationRequires refresh, more steps

When to choose each

  • Use MOD or subtract INT for everyday worksheet analysis.
  • Use Power Query when importing external data or handling millions of rows.
  • Use TEXT only for display-only tasks like labels in charts.
  • Use Flash Fill for one-off corrections in ad-hoc files.

If you need to migrate from TEXT to numeric, wrap existing TEXT formulas inside TIMEVALUE and re-format.

FAQ

When should I use this approach?

Use it whenever you need numeric time values for calculations: grouping by hour, measuring durations, or conditional formatting based on shift boundaries. It is ideal for schedules, manufacturing logs, call-center analytics, and web server log analysis.

Can this work across multiple sheets?

Yes. Place the MOD formula in a central helper sheet and reference timestamps from other sheets, for example:

=MOD('Raw Log'!B2,1)

You can also define a custom named range TimeOnly with =MOD(Sheet1!A2,1) and use it workbook-wide.

What are the limitations?

Excel cannot represent negative dates and times, so logs that cross before 00:00 on 0-Jan-1900 will error. Midnight values return zero, which may appear blank. Excel stores time with precision to the second (1/86,400). Nanosecond precision is impossible without helper columns.

How do I handle errors?

Wrap the formula:

=IFERROR(MOD(A2,1),"Invalid Timestamp")

Filter out error strings, or highlight them with conditional formatting. If source data is text, convert with VALUE first.

Does this work in older Excel versions?

MOD has existed since Excel 2000, so you are safe. However, 2003 and earlier handle custom time formats differently; verify the format code. Power Query methods require Excel 2010 or later with the Power Query add-in, and Data Model requires 2013+.

What about performance with large datasets?

On 100,000 rows, MOD recalculates in under a second on modern hardware. Store data in an Excel Table to leverage fast spill-down. For millions of rows, push the extraction into Power Query or Power Pivot to avoid worksheet overhead.

Conclusion

Extracting the time portion of a date-and-time value is a deceptively simple skill that unlocks powerful analyses: shift-based KPIs, peak-hour dashboards, and precise duration calculations. Whether you prefer the elegant MOD function, Power Query transformations, or quick Flash Fill, mastering this technique streamlines data cleaning and ensures your time-centric reports are accurate and dynamic. Add it to your Excel toolbox, experiment with real datasets, and combine it with pivot tables, charts, and conditional formatting to elevate your analytical projects. Happy time slicing!

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve.