Get work hours between dates and times

osalman

New Member
Joined
Mar 12, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Dear all,
Can you please help me to calculate the working house for the below example?
1.Saturday & Sunday off.
2.Working hours from 07:30 AM to 15:30 PM (Monday to Thursday).
3.Friday from 07:30 AM to 12:00 PM.
4.Excluding holidays.
Many thanks in advance.

Start date (DD-MM-YYYY HH:MM)End date (DD-MM-YYYY HH:MM)Working hours
09-03-2022 09:45 AM14-03-2022 10:25 AM
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi,

You have provided no information regarding Holidays, you can add them in the formula.
Assuming Start and End Dates will Not be on Saturday, Sunday or Holiday.

This is what I came up with:

Book3.xlsx
ABCD
1Start date (DD-MM-YYYY HH:MM)End date (DD-MM-YYYY HH:MM)Working hours
23/9/2022 9:453/14/2022 10:2523.33
323 Hours 20 Mins<Custom Format [h] "Hours" mm "Mins"
Sheet3
Cell Formulas
RangeFormula
C2C2=IF(WEEKDAY(A2,2)<5,15.5/24-MOD(A2,1),0.5-MOD(A2,1))*24+NETWORKDAYS.INTL(A2+1,B2-1,"0000111")*8+NETWORKDAYS.INTL(A2+1,B2-1,"1111011")*4.5+IF(WEEKDAY(B2,2)<5,15.5/24-MOD(B2,1),0.5-MOD(B2,1))*24
C3C3=(IF(WEEKDAY(A2,2)<5,15.5/24-MOD(A2,1),0.5-MOD(A2,1))*24+NETWORKDAYS.INTL(A2+1,B2-1,"0000111")*8+NETWORKDAYS.INTL(A2+1,B2-1,"1111011")*4.5+IF(WEEKDAY(B2,2)<5,15.5/24-MOD(B2,1),0.5-MOD(B2,1))*24)/24
 
Upvote 0
Hi jtakw,
Thank you so much for the support.
please what will be the cell format for C2.
Many thanks in advance.

You have provided no information regarding Holidays, you can add them in the formula.
Assuming Start and End Dates will Not be on Saturday, Sunday or Holiday.

This is what I came up with:

Book3.xlsx
ABCD
1Start date (DD-MM-YYYY HH:MM)End date (DD-MM-YYYY HH:MM)Working hours
23/9/2022 9:453/14/2022 10:2523.33
323 Hours 20 Mins<Custom Format [h] "Hours" mm "Mins"
Sheet3
Cell Formulas
RangeFormula
C2C2=IF(WEEKDAY(A2,2)<5,15.5/24-MOD(A2,1),0.5-MOD(A2,1))*24+NETWORKDAYS.INTL(A2+1,B2-1,"0000111")*8+NETWORKDAYS.INTL(A2+1,B2-1,"1111011")*4.5+IF(WEEKDAY(B2,2)<5,15.5/24-MOD(B2,1),0.5-MOD(B2,1))*24
C3C3=(IF(WEEKDAY(A2,2)<5,15.5/24-MOD(A2,1),0.5-MOD(A2,1))*24+NETWORKDAYS.INTL(A2+1,B2-1,"0000111")*8+NETWORKDAYS.INTL(A2+1,B2-1,"1111011")*4.5+IF(WEEKDAY(B2,2)<5,15.5/24-MOD(B2,1),0.5-MOD(B2,1))*24)/24
 
Upvote 0
Thank you so much for the support.
please what will be the cell format for C2.
Many thanks in advance.

No custom format for C2, just use either C2 formula (as-is) or C3 formula (with Custom format).
 
Upvote 0
Assuming Start and End Dates will Not be on Saturday, Sunday or Holiday.
Hi,
Please we have to consider in the formulas that customer can use the system during the weekends , holidays and after the working hours.
Holidays are in the attached excel sheet with some data.
Many thanks in advance.

Test.xlsx
DEF
1Created On dd/mm/yyyy hh:mm ddddEnd on dd/mm/yyyy hh:mm ddddWorking Hours
211/03/2022 20:02 Friday12/03/2022 21:40 Saturday
311/03/2022 11:50 Friday12/03/2022 21:40 Saturday
411/03/2022 11:18 Friday12/03/2022 21:40 Saturday
510/03/2022 15:08 Thursday12/03/2022 21:40 Saturday
610/03/2022 14:24 Thursday12/03/2022 21:40 Saturday
709/03/2022 17:27 Wednesday12/03/2022 21:40 Saturday
809/03/2022 13:33 Wednesday12/03/2022 21:40 Saturday
909/03/2022 7:57 Wednesday12/03/2022 21:40 Saturday
1008/03/2022 15:07 Tuesday12/03/2022 21:40 Saturday
1108/03/2022 11:30 Tuesday12/03/2022 21:40 Saturday
1207/03/2022 9:49 Monday12/03/2022 21:40 Saturday
1304/03/2022 9:52 Friday12/03/2022 21:40 Saturday
1401/03/2022 8:57 Tuesday12/03/2022 21:40 Saturday
1525/02/2022 10:09 Friday12/03/2022 21:40 Saturday
1622/02/2022 15:04 Tuesday12/03/2022 21:40 Saturday
1710/02/2022 10:36 Thursday12/03/2022 21:40 Saturday
18
19Holidays dd/mm/yyyy
20Dates
2101/01/2022
2230/04/2022
2301/05/2022
2402/05/2022
2509/07/2022
2610/07/2022
2711/07/2022
2831/07/2022
2909/10/2022
3001/12/2022
3102/12/2022
Test
Cells with Data Validation
CellAllowCriteria
D2:D31Date>=01/01/1900
 
Upvote 0
Hi,
Please we have to consider in the formulas that customer can use the system during the weekends , holidays and after the working hours.
Holidays are in the attached excel sheet with some data.
Many thanks in advance.

Please confirm what happens if your customer uses the system "during the weekends, holidays and after the working hours", and also Before working hours.
Do those hours get counted?
Or Free, not counted?
 
Upvote 0
Please confirm what happens if your customer uses the system "during the weekends, holidays and after the working hours", and also Before working hours.
Do those hours get counted?
Or Free, not counted?
Not counted.
We need to count only the working hours (8 hours from Monday to Thursday and 4.5 hours in Friday) even if the customer use the system during the weekends, holidays and after the working hours.
Regards,
 
Upvote 0

Forum statistics

Threads
1,224,862
Messages
6,181,466
Members
453,045
Latest member
Abraxas_X

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top