Yes, you can extract only the time portion from a full date and time value in Excel using the TEXT function with the "h:mm AM/PM" format code, or by subtracting the date from the cell using the INT function. Both methods work instantly to convert values like 12/31/2023 6:30:00 PM into 6:30 PM without altering the original data. This guide covers the most reliable ways to isolate the time component, handle 24-hour formats, and ensure the result displays correctly as a time value rather than text.
What You'll Need
- A computer with Microsoft Excel installed (Excel 2010 or later is recommended for full functionality).
- A dataset containing cells with values that are stored as "Date/Time" (Excel recognizes these if the date and time are combined).
- A basic understanding of how Excel stores dates as serial numbers (dates are whole numbers, times are decimal fractions).
Step-by-Step
- Open your Excel workbook. Navigate to the worksheet containing the full date and time values you wish to separate.
- Select a blank cell. Click on an empty cell where you want the extracted time to appear. This cell will contain the result of your formula.
- Enter the TEXT function. Type the following formula into the selected cell:
=TEXT(A1, "h:mm AM/PM")(assuming your full date is in cell A1). The first argument is the cell reference, and the second argument is the format code. - Press Enter. Press the Enter key on your keyboard. Excel will calculate the value and display the time portion, such as 5:45 PM, in the cell.
- Verify the format. Look at the selected cell. If the result appears as a number (e.g., 0.240), the cell is still formatted as a Number rather than a Time. To fix this, right-click the cell, select Format Cells (or press Ctrl+1), go to the Number tab, choose Time from the category list, and select a time format that includes AM/PM or hours/minutes.
- Drag to apply to other cells. Click the small square in the bottom-right corner of the cell containing your formula (the fill handle) and drag it down to apply the formula to the rest of your dataset. Excel will automatically adjust the cell references (A1, A2, A3, etc.) for each row.
- Use the INT subtraction method (Alternative). If you prefer not to use the TEXT function and want to keep the result as a true time serial number, enter this formula:
=A1-INT(A1). This subtracts the integer part of the date (the date) from the full value, leaving only the decimal part (the time). For example, if A1 is 12/31/2023 6:30:00 PM, the formula returns 0.2708333. - Format the result of the INT method. As with the TEXT method, the result of the subtraction will likely appear as a decimal number. Select the cells, press Ctrl+1, go to the Number tab, choose Time, and select a format like 13:30 or h:mm AM/PM to view the time clearly.
- Handle 24-hour formats. If your original data uses a 24-hour clock (e.g., 18:00 instead of 6:00 PM) and you want to keep it that way, change the format code in the TEXT function to
"hh:mm". The double "h" ensures that hours are shown with a leading zero for single-digit hours (e.g., 09:00 instead of 9:00). - Consider date preservation. The TEXT function always returns a text string, not a time value. This means you cannot perform mathematical operations (like adding 1 hour to the time) on the result. If you need to use the time in calculations, stick with the
=A1-INT(A1)method, but remember to format the cell as a Time type.
Common Mistakes
A common error is using a single "h:mm" format code when working with times after midnight. In Excel, a single h is designed for 12-hour clocks and resets to zero after 12:59 PM. To correctly handle times like 13:00 (1:00 PM) or 23:59 (11:59 PM) without the AM/PM indicator, you must use the double hh format code, as shown in Step 9.
Another frequent issue arises when users forget to apply the correct number formatting. If you use the =A1-INT(A1) method and the cell displays a long decimal number (e.g., 0.7180556), the data is still there, but Excel is interpreting it as a number. Applying the Time format via Format Cells is essential to make the information readable.
Tips
When working with large datasets, remember that Excel stores dates as whole numbers and times as decimal fractions of a day. This mathematical relationship is why subtracting the integer part of a cell effectively isolates the time. You can verify this by typing a time into an empty cell (e.g., 6:30 PM) and changing its format to Number. You will see it displayed as 0.2708333.
For the most flexibility, consider using a helper column. This allows you to keep your original data intact while creating a new column with the extracted time. This makes auditing your spreadsheet easier because you can always see the full original value in one column and the processed time in the adjacent column.
Troubleshooting
The result shows the full date and time. If the formula returns the entire date and time string (e.g., 12/31/2023 6:30:00 PM) instead of just the time, it is because the cell is still formatted as a Date. Select the cell, press Ctrl+1, go to the Number tab, choose Time, and select a time format.
The result shows a negative number or ######. If you are using the =A1-INT(A1) method and the result is negative or displays as hash marks (######), it usually means the original cell does not contain a valid date/time. Check the source data to ensure that the cell contains a value that Excel recognizes as a date. Sometimes, a cell may look like a date but is actually text, which will cause this error.
The time is not converting correctly for times after 12:00 PM. As mentioned in the Common Mistakes section, this is almost certainly a formatting issue. If you are using the TEXT function with "h:mm AM/PM", ensure that the cell format is not set to Number or General. If the cell format is correct and the issue persists, try changing the format code to "hh:mm AM/PM" to force the double-digit hour display.
Frequently Asked Questions
Does the TEXT function change the underlying data type?
No, the TEXT function converts the value into a text string. This means you cannot use the result in further calculations that require a time value, such as adding hours to the time. If you need to use the time for math, use the subtraction method =A1-INT(A1).
How do I extract the time from a cell that is formatted as text?
If the cell contains text that looks like a date and time (e.g., the string "12/31/2023 6:30 PM"), you may need to convert it to a proper Excel date-time value first. You can do this by using the DATEVALUE function on the date part and the TIMEVALUE function on the time part, then adding them together. Alternatively, if the text was originally imported from a CSV file, you can change the data type of the column to Date in the Data tab.
Why does the time show as 0.5 or another decimal number?
Excel stores times as decimal fractions of a day. 0.5 represents 12:00 PM (noon) because it is half of a full day. This is normal behavior. To view it as a time, you simply need to apply the Time number format to the cell.
Can I use these formulas on a Mac?
Yes, the formulas described here (=TEXT(A1, "h:mm AM/PM") and =A1-INT(A1)) work identically on both Windows and Mac versions of Excel. The only difference is that the keyboard shortcut for Format Cells is Cmd + 1 on a Mac, whereas it is Ctrl + 1 on Windows.
What is the difference between "h" and "hh" in the format code?
The single h is used for 12-hour formats and will reset to 0 after 12:59 PM. The double hh is used for 24-hour formats and will display hours from 00 to 23. Use hh if your data is in 24-hour format or if you want to ensure single-digit hours have a leading zero.