Rounding to a Half Hour and Formatting the Display

Written by Allen Wyatt (last updated September 16, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


Lorene has a column that contains various times of day. She needs to round the times to the nearest half hour and display them as, for example, 10 am and 10:30 am. (Lowercase, minutes shown for only the half hour, and lowercase am/pm indicator.) She wonders if this is something she can do with a custom format, or if she needs to use a formula.

The short answer is that you cannot get the desired result with just a custom format. Instead, you'll need to use three features of Excel: a formula, a custom format, and a conditional format, all working in conjunction with each other. How you can round times has been covered in a different ExcelTip, here:

https://tips.net/T11401

To boil it down succinctly, in Lorene's case you could round the time to the nearest half hour in the following manner:

=MROUND(A1,"0:30")

This assumes, of course, that the original time is in cell A1. You can then apply the following custom format to the result of the formula:

h:mm a/p\m

This will display the results of the formula as hours and minutes with an am/pm indicator. This, however, still isn't quite what Lorene is looking for, which is no minutes indicated if the minutes are ":00". The final step can be accomplished by adding a conditional format to the cell. Assuming that your formula is in cell B1, follow these steps:

  1. Select cell B1.
  2. Make sure the Home tab of the ribbon is displayed.
  3. Click the Conditional Formatting tool. Excel displays a series of choices.
  4. Click New Rule. Excel displays the New Formatting Rule dialog box.
  5. In the Select a Rule Type area at the top of the dialog box, choose Use a Formula to Determine Which Cells to Format. (See Figure 1.)
  6. Figure 1. The New Formatting Rule dialog box.

  7. In the formula space, enter the following formula:
  8.      =MINUTE(B1)=0
    
  9. Click on the Format button. Excel displays the Format Cells dialog box.
  10. Make sure the Number tab is selected.
  11. Click Custom at the bottom-left side of the dialog box. (You are setting a custom format to be used if the formula in step 6 is True.)
  12. In the Type box, enter the following format:
  13.      h a/p\m
    
  14. Click OK to close the Format Cells dialog box.
  15. Click on OK to close the New Formatting Rule dialog box.

That's it; the cell will now display the formatted time value as Lorene desired.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13913) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Field Reference to Number of Prior Pages

Fields are used for all sorts of purposes in Word, but typically to provide some sort of dynamic information. This tip ...

Discover More

Relative References to Cells in Other Workbooks

When you construct a formula and click on a cell in a different workbook, an absolute reference to that cell is placed in ...

Discover More

Displaying the First Worksheet in a Macro

When creating macros, you often have to know how to display individual worksheets. VBA provides several ways you can ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Calculating TV Time

In some industries it is necessary to work with time resolutions of less than a second. If you need to keep track of such ...

Discover More

Entering Large Time Values

If you need to input humongous times into a worksheet, you may run into a problem if you need to enter times greater than ...

Discover More

Dealing with Large Numbers of Seconds

When adding values to a time to calculate a new time, you may naturally choose to use the TIME function. This can cause ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four less than 7?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.