I am using SQL Server 2014 and I have tried several things before asking here.
What I need to accomplish is this:
I have a table which stores two time columns, which have values for example like 9:00 or 2:34 etc etc.
I need to calculate the daily hours and the night hours of works.
The daily hours have to be counted from 8:00 to 20:00 and the night ones from 20:00 to 8:00
If I have two time fields there can be values as
4:00 and 12:00
12:00 and 20:00
22:00 and 6:00
What I want to do is to retrieve two decimal values that correspond to the daily hours and the night hours, maybe there's a SQL function i don't know which passing two values and a range do this task for me, or maybe it's the case to build one on my own