excel working out formula

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Excel working out a formula for a 7 hour working day and average

Excel working out a formula for a 7 hour working day and average

resolvedResolved · High Priority · Version 2010

Sam has attended:
Excel Advanced course

Excel working out a formula for a 7 hour working day and average

Hi,

I have an query I need answering:

There is queries that are raised at work through a platform, when we download the data we split it into time created and time it was resolved.

I want to work out the time it took between creation and being resolved. However this is the problem -

How do I work out the resolution time for a 7 hour day format, i.e if a query is raised a 4:30pm on a Thursday and resolved at 10:00am on a Friday the resolution time (based on working 9-5) should be: 0 days 1 hour 30 mins 0 seconds or 00:01:30:00.

I need this for a large spreadsheet, I also have the queries split into categories and want to work out average time it takes to resolve a query per category.

If you could help this would be great!!!

This is an example of the data i work with

Created Resolved
02/04/2018 08:17 03/04/2018 09:05
03/04/2018 08:13 03/04/2018 09:15
03/04/2018 09:21 06/04/2018 09:09
03/04/2018 13:20 04/04/2018 09:53
03/04/2018 14:24 11/04/2018 16:29
03/04/2018 15:45 03/04/2018 15:49
04/04/2018 01:49 04/04/2018 07:52
04/04/2018 08:12 04/04/2018 09:44
04/04/2018 08:36 04/04/2018 09:07


Thanks,

Sam

Edited on Wed 18 Apr 2018, 11:14

RE: Excel working out a formula for a 7 hour working day and ave

Hi Sam,

Thank you for the forum question.

I have some questions

Do you work with working days Monday to Friday?

You only want to calculate time spent within the range 9:00 to 17:00?

You want to calculate a whole day as 7 hours? but the time range 9:00 to 17:00 is 8 hours. If the Created is 10/10/2017 11 am and Resolved is 11/10/2017 10:45 am the result is 7 hours 45 min. should this be displayed as 1 day 45 min.?

You cannot get the result like: 0 days 1 hour 30 mins 0 seconds or 00:01:30:00 and from this calculate average. You will have to have the result 00:00:00 (hours:minutes:seconds). Excel can display "0 days 1 hour 30 mins 0 seconds" but only as a text string and then you will not be able to calculate average.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Excel working out a formula for a 7 hour working day and ave

Hi Sam,


Do you work with working days Monday to Friday

- Yes a working week for us is Monday to Friday

You only want to calculate time spent within the range 9:00 to 17:00

- Yes

You want to calculate a whole day as 7 hours? but the time range 9:00 to 17:00 is 8 hours. If the Created is 10/10/2017 11 am and Resolved is 11/10/2017 10:45 am the result is 7 hours 45 min. should this be displayed as 1 day 45 min.? -

- 8 hours is fine was just thinking about an hour for lunch but that doesn't matter, stick with 8.

Having the time in (Hours:Minutes:Seconds) is fine i just don't know how to quantify it to the 8 hour day. Also if its 7 hours 45 mins having 1 day 45 mins displayed is fine also. I just need to be able to calculate the average after if those values are in a list. So yes i do not want the text string method.

Thanks,

Sam

RE: Excel working out a formula for a 7 hour working day and ave

Hi Sam,

Thank you for a challenging question.

I think I have got it.

In my example I have:
Created date in column A
Created time in column B
Resolved date in column C
Resolved time in column D
Start time (09:00) in G1
End time (17:00) in H1


=MAX(0,IF((NETWORKDAYS(A2,C2)-2)<0,IF(B2<D2,MIN(D2,$H$1)-MAX(B2,$G$1),MAX(0,$H$1-B2)+MAX(0,D2-$G$1)),(NETWORKDAYS(A2,C2)-2)*8/24+IF(B2<D2,MIN(D2,$H$1)-MAX(B2,$G$1),MAX(0,$H$1-B2)+MAX(0,D2-$G$1))))

I hope it makes sense.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Excel working out a formula for a 7 hour working day and ave

Hi Jen,

Thanks so much for your help! have you got an example of the excel file you could attach to this?

I am trying now but cant seem to get it to work for example:

02/04/2018 08:17 03/04/2018 09:05 09:00:00 17:00:00 0.708333333

The answer I am getting here is 0.7083333

Thanks,

Sam

RE: Excel working out a formula for a 7 hour working day and ave

Hi Sam,

Wait a little bit spending time with my solution, I have spotted an error in the functions.

I will be back.

The cells where you want the result must be custom formatted. The code for the formatting is:

[hh]:mm:ss

If the cells are time formatted Excel will not allow more than max 24 hours by putting square brackets around hh there is no limit for number of hours.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Excel working out a formula for a 7 hour working day and ave

OK so i will wait for you to send back the solution as you need to work on the forumla?

RE: Excel working out a formula for a 7 hour working day and ave

Hi Sam.

Please find formula below:


=MAX(0,IF((NETWORKDAYS(A2,C2)-1)<2,IF(B2<D2,MIN(D2,$H$1)-MAX(B2,$G$1),MAX(0,$H$1-B2)+MAX(0,D2-$G$1)),IF(TIME(HOUR(B2),MINUTE(B2),SECOND(B2))-TIME(HOUR(D2),MINUTE(D2),SECOND(D2))>0,(NETWORKDAYS(A2,C2)-2)*8/24+IF(B2<D2,MIN(D2,$H$1)-MAX(B2,$G$1),MAX(0,$H$1-B2)+MAX(0,D2-$G$1)),IF(TIME(HOUR(B2),MINUTE(B2),SECOND(B2))-TIME(HOUR(D2),MINUTE(D2),SECOND(D2))=0,(NETWORKDAYS(A2,C2)-2)*8/24+IF(B2<D2,MIN(D2,$H$1)-MAX(B2,$G$1),MAX(0,$H$1-B2)+MAX(0,D2-$G$1)),(NETWORKDAYS(A2,C2)-1)*8/24+IF(B2<D2,MIN(D2,$H$1)-MAX(B2,$G$1),MAX(0,$H$1-B2)+MAX(0,D2-$G$1))))))


And as I mentioned earlier the result cells must be custom formatted using the code: [hh]:mm:ss


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Excel working out a formula for a 7 hour working day and ave

Hi Jenny,

Im getting the follwing:

02/04/2018 08:17 03/04/2018 09:05 09:00 17:00 00:05:00

The answer with the right formatting in the result cell is wrong is 00:05:00?

Theres no minutes either?

Sam

RE: Excel working out a formula for a 7 hour working day and ave

Hi Sam,

Please replace =MAX(0,IF((NETWORKDAYS(A2,C2)-1)<2 with =MAX(0,IF((NETWORKDAYS(A2,C2)-1)<1

(in the beginning of the formula change <2 to <1)

Then it will return 08:05:00 there is 8 hours a whole working + 5 minutes

From 9 to 5 the 2/4/2018 8 hours and from 9 to 9:05 the 3/4/2018 5 min.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Excel working out a formula for a 7 hour working day and ave

Thanks Jenny much appreciated!!

Sam

RE: Excel working out a formula for a 7 hour working day and ave

Hi Sam,


In the Networkday function you can add a holiday list (bank holidays or other days you don't want to be working days).


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector


 

Excel tip:

Quickly select a block of data

To quickly select a block of data make sure your active cell is somewhere whithin the block of data and then press Ctrl+* or Ctrl+Shift+8.

View all Excel hints and tips


Server loaded in 0.08 secs.