Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is datetime more than 48 hours ago?
Message
From
23/01/2017 13:00:56
 
 
To
23/01/2017 09:56:02
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Miscellaneous
Thread ID:
01646961
Message ID:
01646964
Views:
46
This message has been marked as a message which has helped to the initial question of the thread.
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.
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