Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting number of working hours
Message
 
 
À
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:
01618778
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.

Use SUM (CAST(Temp.SecondValue as DECIMAL(22,2))) /3600
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform