Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting number of working hours
Message
De
20/04/2015 10:05:22
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01618554
Message ID:
01618769
Vues:
28
After verification, the WHERE clause need to be like this so to include in the record set the minimum and maximum values:
DECLARE @Start DATETIME
DECLARE @End DATETIME
DECLARE @Start2 DATETIME
DECLARE @End2 DATETIME
 
SET @Start='2014-01-23 09:15:00'
SET @End='2014-01-29 13:16:00'
SET @Start2='2014-01-23 08:00:00'
SET @End2='2014-01-29 17:00:00'
 
SELECT SUM(Temp.SecondValue)/3600 AS HourValue
FROM (SELECT DATEDIFF(SECOND,
 CASE WHEN BusinessTime.Start>@Start THEN BusinessTime.Start ELSE @Start END,
 CASE WHEN BusinessTime.[End]<@End THEN BusinessTime.[End] ELSE @End END) AS SecondValue
 FROM BusinessTime
 WHERE BusinessTime.NoProvince=84 AND
  BusinessTime.Start>=@Start2 AND BusinessTime.Start<=@End2 AND
  BusinessTime.[End]>=@Start2 AND BusinessTime.[End]<=@End2) Temp
However, the /3600 rounds the value. I need to find a way to collect the decimals.
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform