Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Want to Calculate Business Working hours Expand / Collapse
Author
Message
Posted Thursday, November 8, 2007 12:33 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 23, 2013 12:50 AM
Points: 16, Visits: 113
hi Everyone,

I have one query, i want to calculate the business working hours (like from monday to friday 9 to 5 pm and saturday 9 to 2 pm) for the given 2 dates. And also i want to eliminate the public holidays with in the given dates.



If any one was faced the same situation plz help me.




Regards

Venki
Post #419938
Posted Thursday, November 8, 2007 1:21 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 16, 2014 4:11 AM
Points: 2,397, Visits: 3,416
I think there already are about 15 zillion postings about this exact problem.
Try to search this forum for similar requests and see what you get?



N 56°04'39.16"
E 12°55'05.25"
Post #419946
Posted Thursday, November 8, 2007 2:40 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 23, 2013 12:50 AM
Points: 16, Visits: 113
i got one example, but it is useful only for calculating the number of working days.

url is: http://weblogs.sqlteam.com/brettk/archive/2005/05/12/5139.aspx

If anyone knows my query plz respond me.


Its very urgent.
Post #419959
Posted Thursday, November 8, 2007 8:47 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, January 9, 2014 3:33 AM
Points: 1,559, Visits: 672
You may find your way to your answers here:
http://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using-an-auxiliary-calendar-table.html

/Kenneth



Post #420120
Posted Thursday, November 8, 2007 9:08 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:07 PM
Points: 7,105, Visits: 15,433
well - let's get some specifics before we go diving into weeks and weeks of back and forth (well - probably will happen anyway.....:D)

Jeff Moden took a running start at whole days in a recent article. [url=http://www.sqlservercentral.com/articles/Advanced+Querying/calculatingworkdays/1660/][/url]

- What do you plan on passing in? Are we dealing with specific work time starts and stops (e.g. 9/1/07 10:20am to 10/15/07 1:55pm) or full days? Are they passed in combined, or separated? (e.g. Start datetime, end datetime vs start date, start time, end date, end time)
- what - no lunch breaks?
- where are you storing your holidays?


----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #420133
Posted Monday, November 12, 2007 12:03 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 23, 2013 12:50 AM
Points: 16, Visits: 113
We are storing holidays list in seperate table. And also storing the Business hours in that table.

We are storing the data in datetime format. I want to calculate the hours and minutes in between the passed dates(datetime format).


Give me solution Plz


Thanks & Regards
Venki
Post #420921
Posted Monday, November 12, 2007 1:44 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, January 9, 2014 3:33 AM
Points: 1,559, Visits: 672
Ok, could you then please give an example on what this table of yours look like?
A few rows of sample data and the expected output you need from that data.

/Kenneth



Post #420939
Posted Monday, November 12, 2007 2:21 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 23, 2013 12:50 AM
Points: 16, Visits: 113
For this i am using 2 tables i.e., Holidays and WorkingHours. We are storing only holidays dates in holidays table. in working hours table 3 columns were there i.e., weekday, starting time, closing time.
we are storing the values like from monday to friday 9 am to 5 pm and for saturday 9 am to 1 pm.

thanks & regards

Venki
Post #420949
Posted Tuesday, November 27, 2007 9:39 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Sunday, August 3, 2014 3:03 PM
Points: 378, Visits: 2,403
Hi Venki,
Here is the answer to your problem.

http://www.sqlservercentral.com/scripts/Scalar-valued+Functions/61567/

As I understand from your description, you need to do the following modifications to get what you exactly need.

1. The function CalcTimeSinceCreated will have to be modified to take two parameters case as 'task beginning date&time' and 'task ending date&time', instead of one at present

2. I am hardcoding the working hours and weekdays in the functions. You need to modify it to take this information from 2 tables i.e., Holidays and WorkingHours.

If you provide me the exact structure of your two tables and a few rows of the sample data then I may help you in the above two tasks.

Regards,
Mazharuddin


-----------------------------------------------------------
Time Is Money
Calculating the Number of Business Hours Passed since a Point of Time
Calculating the Number of Business Hours Passed Between Two Points of Time
Post #426468
Posted Wednesday, November 28, 2007 9:27 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 23, 2013 12:50 AM
Points: 16, Visits: 113
HI Mazharuddin

I AM VERY MUCH THANKFUL TO YOU FOR YOUR SOLUTION.

I AM WORKING ON THAT NOW.

ONCE AGAIN THANKS


REGARDS
VENKI
Post #427228
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse