IIF statement and add hours in Excel

Posted on 2007-08-10
Last Modified: 2008-01-09
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.  
Question by:jjrr007
    1 Comment
    LVL 85

    Accepted Solution

    You could use:

    or put the values into a lookup table and reference them with a lookup formula.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    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…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now