![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
I wish to calculate how many WORKING hours between 2 dates. The ricky bit is I want it to also disregard weekends and ideally bank holidays. eg 10/02/02 09:00 and 14/02/02 10:00 (where 11th and 12 are Sat/Sun), I want it to come back with 9 hours.
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,314
|
Quote:
|
|
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
Sorry.....I knew what I meant.....8 working hours a day (9 till 5 is 8 hours)and in my example i quoted till 10am the next working day i.e. 8 hours plus 1 hour the next day. Basically, if I use networkdays function I get a result of 1, where as I want to know the number of hours, not days! I need the calculation to take weekends out of the result.
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
Edited:
=IF(NETWORKDAYS(A1,B1)>2,(NETWORKDAYS(A1,B1)-2)*8+(("17:00"-MOD(A1,1))+(MOD(B1,1)-"9:00"))*24,IF(INT(A1)=INT(B1),(B1-A1)*24,(("17:00"-MOD(A1,1))+(MOD(B1,1)-"9:00"))*24)) to allow for correct calc on same day. Original =IF(NETWORKDAYS(A1,B1)>2,(NETWORKDAYS(A1,B1)-2)*8+(("17:00"-MOD(A1,1))+(MOD(B1,1)-"9:00"))*24,(("17:00"-MOD(A1,1))+(MOD(B1,1)-"9:00"))*24) do the trick? start time date is A1, end time date is B1. Quote:
|
|
|
|
|
|
|
#5 |
|
Guest
Posts: n/a
|
Fantastic!! Many thanks for your help. Works a treat! (how come you know how to do this?)
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
I'm glad it works for you. As for why I know how, that's a good question. I think it all goes back to reading a Mark W. posting for probably the 100th time that he said excel stores time as a fraction of a day (1 = 24 hours). Once you understand that and the odd formats that sometime pop up, a farily simply formual can usually solve the problem. By the way, if you need this formula to show true time, just divide it by 24 with a [h]:mm format
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|