Mensaje
De
23/01/2017 13:10:01
 
 
a
23/01/2017 13:00:56
General information
Foro:
Microsoft SQL Server
Category:
Sintáxis SQL
Environment versions
SQL Server:
SQL Server 2012
Miscellaneous
ID de la conversación:
01646961
ID del mensaje:
01646966
Views:
26
>I see you adjusted to DateDiff(). Yes, that would be the approach to go. I have a similar process and that is the best I have found sofar. The usage of Second() is also a good fit. To handle the decimals, I ended up with something like this:
>
>
>SELECT COALESCE(SUM(Temp.[Second])/3600.0,0)
> FROM (SELECT DATEDIFF(SECOND,
> CASE WHEN BusinessTime.Start>Client.AddDate THEN BusinessTime.Start ELSE Client.AddDate END,
> CASE WHEN BusinessTime.[End]<Client.FirstContactDate THEN BusinessTime.[End] ELSE Client.FirstContactDate END) AS [Second]
> FROM BusinessTime
> WHERE BusinessTime.Start<Client.AddDate AND
> BusinessTime.[End]>=Client.FirstContactDate) Temp
>
>
>This is basically and adaption of what it is actually. But, that should give you an idea on the DateDiff() usage with Second, which is then divided by 3600. In my case, I wanted to have that in hours. So, that changed the decimal value into hours, which has decimal support with the ,0.

Thanks
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Responder
Mapa
Ver