Home SQL select hours from two time fields but between a range
Reply: 0

SQL select hours from two time fields but between a range

user797
1#
user797 Published in July 22, 2018, 6:20 pm

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

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.356318 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO