• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

IIF statement and add hours in Excel

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
jjrr007
Asked:
jjrr007
1 Solution
 
Rory ArchibaldCommented:
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now