# Excel/Time calculation

Question
I am doing a departure time calculation and need my answer to be restricted to business hours, how can i modify the formula to accomodate departure hours of 8:00AM to 5:00 PM? That is to say, If the calculated departure time is 03/24/2013 6:00 PM, then the formula would return 03/24/2013 5:00 PM, and if the calculated time is 03/24/2013 06:00 AM the formula would return 03/23/2013 5:00 PM. Simply put if the departure time is between 5:00 pm and 11:59 PM then return departure time as 5 PM on the same day, if the departure time is between Midnight and 8:00 AM then return answer should be departure previous day by 5:00 PM.

Jorge:

Please try the following formula (assuming the cell with the time to be modified is in A1):

=IF(OR(MOD(A1,1)>17/24,MOD(A1,1)<8/24),IF(MOD(A1,1)>17/24,DATE(YEAR(A1),MONTH(A1),DAY(A1))+17/24,DATE(YEAR(A1),MONTH(A1),DAY(A1-1))+17/24),A1)

Sincerely,

Nathan
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

#### Nathan

##### Expertise

This expert requires a donation of \$5 for questions answered (satisfaction guaranteed). Isn't \$5 a value for this experts time?
Microsoft Excel questions related to advanced formulas, Pivot Tables, filters, forms, graphs, and just about anything else (EXCEPT Visual Basic Coding/Programming and Macros, I don't answer questions in those categories).

##### Experience

I have been using spreadsheets since Lotus 1-2-3 was released.

Education/Credentials
Certified Public Accountant (CPA)