Taking Time of Day into Account in a Formula

Written by Allen Wyatt (last updated December 6, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


2

Vern runs a small job shop, and they often get people who come in late in the day and want their work done by the end of the day. The shop normally charges these people a 20% rush fee. In pricing a job in a worksheet, Vern would like to have a line that calculates the rush fee, but only if the current time is later than 3:00 pm. If it is later, then rush fee would be equal to 20% of the value in cell E15. Vern wonders if a formula can take the time of day into account in this way.

There are many different formulas that could be used for this purpose. Here, for example, is a very easy one:

=IF(NOW()>TODAY()+TIME(15,0,0),0.2*E15,0)

This works because the NOW function returns the date and time, so if the current time is greater than 3:00 pm, then 20% of what is in cell E15 is returned, otherwise 0 is returned.

There is a potential problem with this formula, however—it will recalculate every time you make a change in the worksheet. Thus, if a customer comes in at 2:45 pm and you spend time with that customer talking about the job (or the weather) that puts the time beyond 3:00 pm, the rush fee would not be included. However, it would be included if you make a change in the worksheet that causes a recalculation.

To get around this potential problem, you may want to put a job time in a different cell. For instance, you might use cell B2 for this purpose. Select that cell, then press Ctrl+Shift+;. Excel puts the current time into the cell. You can then use this formula to calculate the rush fee:

=IF(B2>TIME(15,0,0),0.2*E15,0)

You are, in this iteration, comparing the job time to the 3:00 pm cutoff; it is this time that controls whether the rush fee applies or not. (Now you can talk about the job or weather as much as you want and the job total won't change based on the time.) In order to start a new job calculation, you simply need to remember to update cell B2 with a new time as part of your data entry.

To further refine the formula, you may want to put the rush job cutoff time into its own cell (B3) and the rush job percentage into its own cell (B4). The formula would now look like this:

=IF(B2>B3,B4*E15,0)

Putting these values in their own cell provides an easy way to adjust them without needing to edit the actual formula.

Speaking of the formula, remember that I mentioned there were many ways that such a formula could be written. Regardless, the same considerations apply with those as I've discussed in relation to this particular formula.

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

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

Deleting Styles

As documents evolve, so do your needs for various styles. You may create new ones and, invariably, old ones need to be ...

Discover More

Making VLOOKUP Case Sensitive

The VLOOKUP function, like other lookup functions in Excel, is not case sensitive. In other words, it doesn't matter ...

Discover More

Copying to Very Large Ranges

Using the mouse to select a large cell range can be frustratingly slow. If you want to make copying to a large range of ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Displaying Elapsed Time in Decimal Format

Want to display an elapsed time as a decimal format? It's pretty easy to do, if you know that a very simple formula is ...

Discover More

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

Shortcut to Enter GMT

Entering the current time into a cell is easy, as Excel provides a built-in shortcut to accomplish the task. Here's a ...

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 six more than 0?

2025-12-06 14:15:16

C Lefsrud

Should probably include an input field for the required delivery date/time of the order, to deal with orders which come in after 3:00 but are not required today.


2025-12-06 11:19:43

J. Woolley

The Tip's 3 formulas use IF(...). Since Excel converts TRUE to 1 and FALSE to 0 in numeric calculations, they can be simplified like this:
=(NOW() > TODAY() + TIME(15, 0, 0))*0.2*E15
=(B2 > TIME(15, 0, 0))*0.2*E15
=(B2 > B3)*B4*E15
The Tip says, "There are many different formulas that could be used for this purpose." Here are a few more:
=(MOD(NOW(), 1) > TIME(15, 0, 0))*0.2*E15
=(HOUR(MOD(NOW(), 1)) >= 15)*0.2*E15
=(TEXT(NOW(), "hh") >= "15")*0.2*E15
Notice the last 2 require later than or equal to 3:00 pm, but Vern specified later.
For related discussion, see my comment here: https://excelribbon.tips.net/T012889_Taking_the_Time_into_Account_in_a_Formula.html


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.