Solved

Calculating working hours time span

Posted on 2012-03-19
3
886 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:ScottPletcher
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Backup & Restore 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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now