Solved

Calculating working hours time span

Posted on 2012-03-19
3
904 Views
Last Modified: 2012-03-31
Does anyone have a function to calculate working hours time span between 9am and 5.30pm using the 12 hour clock

I want to calculate averagewaitingtimes using the format below.

 I want  the calculation to exclude bank holidays and weekends and should not be the 24 hour format
The working hours are between 9am  to 5.30pm
I want the calculation to stop at 5.30pm

e.g  
datepricequoterequested -24/10/2011 at 15.00
datepricequotetodistributor  – 24/10/2011 at 16.00
datepricequotefromdistributor – 24/10/ 2011 at 17:00
datepricequoteprocessed  -25/10/2011 at 10:00am
Stop counting from  17:30 and 09:00

e.g
15:00-16:00 1 hour at company
16:00-17:00 1 hour at distributor
17:00 – 17:30 ½ hour at company
09:00 -10:00 1 hour at company
Gives the company 2 ½ hrs


Format is:
datepricequoteprocessed -  (datepricequotetodistributor  - datepricequotefromdistributor)- datepricequoterequested

e.g
25/10/2011 at 10:00am-(24/10/2011 at 16.00-– 24/10/ 2011 at 17:00)- 25/10/2011 at 10:00am
0
Comment
Question by:turaks
3 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 37740281
can you post your table structure? (column names and types)
0
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
ID: 37740612
There's a blog post on a related subject at
http://pratchev.blogspot.com/2008/01/calculating-work-hours.html
and you may find something close in the business maths part at
http://www.totallysql.com/

If you do end up doing it yourself, I think you can best start by creating a dates table, that provides you with all the days that can be utilised (i.e. get weekends and holidays specified so you can skip them).

Then what you imply is that you provide the code with the quoteRequested and quoteProcessed datetimes and distributorOut and distributorIn datetimes, This effectively gives you two periods - from quoteRequested to distributorOut and from distributorIn to quoteProcessed. I think you can get the technique for these two from the blog and then add them ...

hth

Mike
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 37742538
Weekends are easy to determine, but you would need a table with all the bank holidays in it.

The rest of the computation can be done in an expression to determine the total company time.

Presumably average would just be dividing that total company time by the total row count.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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