Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting number of working hours
Message
From
17/04/2015 10:31:59
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01618554
Message ID:
01618634
Views:
42
>Could you post some example data and desired result from it?

For example, if my start and end time is 23/01/2014 09:15:00 and 29/01/2014 13:45:00, the SQL select might return a set of records like this for specific working shifts:

23/01/2014 08:00:00 - 23/01/2014 12:00:00
23/01/2014 13:00:00 - 23/01/2014 17:00:00
24/01/2014 08:00:00 - 24/01/2014 12:00:00
24/01/2014 13:00:00 - 24/01/2014 17:00:00
27/01/2014 08:00:00 - 27/01/2014 12:00:00
27/01/2014 13:00:00 - 27/01/2014 17:00:00
28/01/2014 08:00:00 - 28/01/2014 12:00:00
28/01/2014 13:00:00 - 28/01/2014 17:00:00
29/01/2014 13:00:00 - 29/01/2014 17:00:00

That could represent, for example, Thursday, Friday, Monday, Tuesday and Wednesday afternoon, assuming Wednesday morning was a holiday.

Those would have been selected because they fit within the range of the start and end dates.

So, here, I need to obtain 32.00 hours because this is the total amount of working hours that were eligible between the two dates.

If the start and end time would be 23/01/2014 09:20:00 and 29/01/2014 13:45:00, that would give 31.95 hours.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform