Convert an hour to 12-hour numbering

Turn the time 2:30:15 PM into the hour 2. Midnight and noon both give 12.

What you'll make

In Excel: 2:30:15 PM becomes 2.

The formula

The formula, with a numbered bracket under each part.
NumberPartWhat it doesResult so far
1HOUR(A8)The hour of the time, from 0 to 23.14
2-1Takes away 1.13
3MOD( … ,12)Keeps what is left after counting in twelves.1
4+1Adds 1 back, so the hours run 1 to 12.2

MOD wraps parts 1 and 2, so Excel works from the inside out.

=MOD(HOUR(A8)-1,12)+1

How to use it

Yellow bar at the top? Click Enable Editing.

  1. See it work. The Example tab shows 20 made-up examples with the formula already in.
  2. Use your own times. Paste real times into the green column of the Template tab. The hours fill in by themselves.
  3. Move them into your letter. Copy the results. Then use Paste Special and choose Values.

Before you send

This gives the hour number only, so 2 AM and 2 PM both give 2. Add AM or PM if you need it.

Microsoft's help: HOUR function