Solved

IIF statement and add hours in Excel

Posted on 2007-08-10
626 Views
I have an Excel Worksheet (2003 Excel Version) that has time in one columns.  I want to write a formula that says, if you add 4 hours to the time and the

Result is Less than 5PM-   Return 5PM
Result is between 5 PM and 9PM- Return 9PM
Result is after 9PM- Return 11:59:59PM

I have the part of the formula to add 4 hours it's: =(D2+TIME(4,0,0))   .  I am not sure how to come up with the iif statement.
0
Question by:jjrr007
1 Comment

LVL 85

Accepted Solution

You could use:
=IF(D2+TIME(4,0,0)<TIME(17,0,0),TIME(17,0,0),IF(D2+TIME(4,0,0)<=TIME(21,0,0),TIME(21,0,0),TIME(23,59,59)))

or put the values into a lookup table and reference them with a lookup formula.
Regards,
Rory
0

Featured Post

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filledâ€¦