Cellwise Start free

Excel guide · 5 min read

Convert 24-hour time to 12-hour AM/PM in Excel

Quick answerIf the cell holds a real time, change its number format: press Ctrl+1, choose Custom and type h:mm AM/PM, and 14:30 shows as 2:30 PM. The value does not change, so sums and sorting still work. For a text label, use =TEXT(B3,"h:mm AM/PM"). To go back to 24-hour, use the format hh:mm.

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCDEFGH
1EmployeeShift startClock-in (raw)Badge exportRoomBooked for
2Ana6:4564506:45Oak9:05 AM
3Ben14:30143014:30Elm2:30 PM
4Chloe22:0022000645Ash10:15 AM
5Dev0:303000:30Oak11:40 PM
6Ema12:00120012:00Elm12:10 PM
7Finn18:15181518:15Ash7:50 AM

Download this sheet as an Excel practice file (.xlsx)

Change the number format (the time stays a time)

Excel stores a time as a fraction of a day: 14:30 is 0.604166..., because 14.5 hours is 60.4% of 24. Whether you see 14:30 or 2:30 PM is only the cell's number format. So the cleanest conversion is to change the format and leave the value alone.

This is the method to pick whenever the column holds real times. You can still subtract them, add them, sort them and use them in lookups. Check first: a real time sits on the right of the cell, and =ISNUMBER(B3) returns TRUE.

  1. Select the times (B2:B7 in the shift sheet above).
  2. Press Ctrl+1 to open Format Cells and click the Number tab.
  3. Choose Custom and type h:mm AM/PM in the Type box. Use h:mm:ss AM/PM if you need seconds.
  4. Click OK. 14:30 now shows as 2:30 PM, and the formula bar still shows the same time.
=B3

Result: 14:30 shows as 2:30 PM with the custom h:mm AM/PM format

The value underneath is Ben's 14:30. With the custom format it displays as 2:30 PM. Use hh:mm AM/PM if you want a leading zero, as in 06:45 AM.

TEXT when the time goes into a sentence

When you join a time to text with &, Excel uses the stored value, not the format, so you would get "Shift starts at 0.604166666666667". Wrap the time in TEXT with the same format code to control how it looks.

TEXT returns text. That is fine for labels, emails and mail-merge columns, but do not use a TEXT column for maths: SUM skips it and comparisons treat it as words. Keep the real time in one column and build labels in another.

="Shift starts at "&TEXT(B3,"h:mm AM/PM")

Result: Shift starts at 2:30 PM

Shift starts at 2:30 PM. Use "am/pm" in lower case in the format code if you want 2:30 pm.

Midnight and noon: the two that confuse people

In 12-hour time, 00:30 is 12:30 AM and 12:00 is 12:00 PM. Excel gets both right, but people reading the sheet often do not, and staff who type times by hand get them wrong. Dev's 0:30 start is just after midnight, and Ema's 12:00 is midday.

When you type times, Excel reads 2:30 as 2:30 in the morning. Type 14:30 or 2:30 PM (with a space before PM) for the afternoon. If a column of afternoon shifts all show AM, they were typed without PM and are 12 hours out.

=TEXT(B5,"h:mm AM/PM")

Result: 12:30 AM

12:30 AM for Dev's 0:30 start. =TEXT(B6,"h:mm AM/PM") gives 12:00 PM for Ema's noon start.

Back from 12-hour to 24-hour

For real times, use the custom format hh:mm (or h:mm). A time format without AM/PM displays in 24-hour style.

Booking systems often export 12-hour times as text, like the "Booked for" column. TIMEVALUE reads text such as "2:30 PM" and returns a real time. Format that result as hh:mm, or wrap it in TEXT if you need 24-hour text for another system.

=TEXT(TIMEVALUE(H3),"hh:mm")

Result: 14:30

14:30. The same formula turns "12:10 PM" into 12:10 and "12:10 AM" into 00:10.

Text times from exports: "14:30", "0645" and 645

Time clocks and HR exports rarely give you clean times. Column D came in as text: "14:30" with a colon works with TIMEVALUE or two minus signs (--D3). Format the result as h:mm AM/PM.

Times with no colon, like 1430, are the harder case. TIMEVALUE("1430") returns #VALUE!, because Excel does not see a time in it. And if the column was opened from a CSV as numbers, 0645 has already lost its leading zero and arrived as 645 (column C). Split the hundreds yourself: INT(C2/100) is the hours and MOD(C2,100) is the minutes. This works for 645, 1430 and 30, and for text like "0645" too.

=TIME(INT(C2/100),MOD(C2,100),0)

Result: 6:45 AM

6:45 AM for Ana's clock-in of 645. C5 (30) gives 12:30 AM and D4 ("0645") gives 6:45 AM with the same formula.

Sort text times in the right order

Text sorts character by character, so "10:15 AM" comes before "2:30 PM" and "9:05 AM" lands last. Sorting the booking column with Data > Sort A to Z, or =SORT(H2:H7), gives 10:15 AM, 11:40 PM, 12:10 PM, 2:30 PM, 7:50 AM, 9:05 AM. The real fix is to convert the column to times first; then Sort Smallest to Largest works.

If you cannot change the column, sort by the converted values instead. In Excel 365 and 2021, SORTBY sorts one range by another, and the other range can be computed on the fly.

=SORTBY(H2:H7,TIMEVALUE(H2:H7))

Result: spills 6 rows × 1 column

7:50 AM
9:05 AM
10:15 AM
12:10 PM
2:30 PM
11:40 PM

7:50 AM, 9:05 AM, 10:15 AM, 12:10 PM, 2:30 PM, 11:40 PM: the bookings in true time order.

Common mistakes

Using TEXT to convert a whole column you still need to calculate with

TEXT returns text, so durations and totals break. Change the number format instead and keep TEXT for labels.

TIMEVALUE on times with no colon

"1430" is not a time to Excel and gives #VALUE!. Use =TIME(INT(C2/100),MOD(C2,100),0), which handles 1430, 645 and "0645".

Typing afternoon times without PM

2:30 is read as 2:30 AM. Type 14:30 or 2:30 PM, then check with =TEXT(B2,"h:mm AM/PM").

Sorting a text time column A to Z

Text sorts "10:15 AM" before "9:05 AM". Convert the times with TIMEVALUE first, or sort with SORTBY(range,TIMEVALUE(range)).

FAQ

How do I convert 24-hour time to 12-hour in Excel?

Select the cells, press Ctrl+1, choose Custom and type h:mm AM/PM. The times stay real times and display as 2:30 PM. For a text result in a formula, use =TEXT(A2,"h:mm AM/PM").

How do I convert 12-hour time to 24-hour in Excel?

Use the custom format hh:mm on real times. If the times are text like "2:30 PM", use =TIMEVALUE(A2) and format the result as hh:mm, or =TEXT(TIMEVALUE(A2),"hh:mm") for text.

How do I convert 1430 to 14:30 in Excel?

Use =TIME(INT(A2/100),MOD(A2,100),0) and format the result as hh:mm or h:mm AM/PM. It works whether the cell holds the number 1430 or the text "1430".

Why does my time show as a decimal like 0.6041?

The cell is formatted as General or Number, so you see the stored fraction of a day. Apply a time format such as h:mm AM/PM and it shows as a time again.

Can I show am and pm in lower case?

Yes. Write the format code in lower case, h:mm am/pm, and Excel shows 2:30 pm. AM/PM in capitals shows 2:30 PM.

Functions used

Related guides

Updated