Military time is just 24-hour time without a colon, so 2:30 PM becomes 1430. The cleanest way is a custom format, which changes the display while leaving the cell a real time you can still calculate with: select the cells, press Ctrl+1 → Custom, delete what’s in the Type box, and enter hhmm.
Use hh:mm if you want the colon kept. The formula alternative is =TEXT(A1,"hhmm"), but that returns text — you can’t subtract two of those or use them in a time calculation, which is why the custom format is the better choice in a working sheet.
Going the other way, if someone has typed 1430 as a plain number, convert it to a real time with =TIME(LEFT(A1,2),RIGHT(A1,2),0) — then format it however you like. And to subtract two military times for a shift length, do it on the real time values (=B1-A1) and format the result as [h]:mm; subtracting 1430 from 2200 as numbers gives 770, not 7 hours 30 minutes.
Convert Normal Time into Military Time
You can use the TEXT function to convert a normal time into military time in Excel. In the following example, we have the time in cells A1 and A2. The first time is in AM and the second is in PM.

Now, by using the TEXT function, you can convert this time into military time, and the formula would be as follows.
=TEXT(A1,"HHMM")

In the format argument, you have the “HHMM” format, which is without a colon and shows the time as military time.
The result keeps the leading zero, so 9:05 AM becomes 0905 and midnight becomes 0000. But TEXT returns text, not a time, so you can’t use the result in time calculations. If you want the 24-hour time with a colon, use “hh:mm” instead (formula below).
=TEXT(A1,"hh:mm")
Get Military Time using Custom Formatting
To use the custom formatting, you need to select the cell or the range of cells where you want to get the military time.

- Once you select the cell, use the shortcut key Ctrl + 1 to open the Format Cells dialog box.
- Click on Custom to go to the custom formatting options.
- From here, click on the Type input box and delete the format that you already have there.
- In the end, enter “HHMM” as a format and click OK.
Unlike the TEXT function, custom formatting only changes how the time looks. The cell still holds a real time value, so you can keep using it in calculations.
Convert Military Time to Normal Time
If you have military time as a number like 1430 in cell B1, the following formula converts it into a real time value. INT(B1/100) gives the hours and MOD(B1,100) gives the minutes. Format the cell as h:mm AM/PM to see 2:30 PM:
=TIME(INT(B1/100),MOD(B1,100),0)
And if you want the result as text with AM/PM in one go, wrap it in TEXT. This also works when the military time is stored as text, like “0930”:
=TEXT(TIME(INT(B1/100),MOD(B1,100),0),"h:mm AM/PM")
Frequently Asked Questions
Why does my military time lose the leading zero?
You have typed it as a number, like 930, and Excel doesn’t keep leading zeros in numbers. Use the custom format 0000 to show it as 0930, or keep the time as a real time value and use the HHMM format.
How do I add or subtract military times?
Convert them into real times first with the TIME formula above, then add or subtract them. If you subtract numbers like 1430 – 0930 directly, you get 500, which isn’t a time.
What is the difference between HHMM and hh:mm?
Both show the time in 24-hour format. HHMM shows it without a colon, the way military time is written (like 2145), while hh:mm adds the colon (21:45).
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.