Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

How to calculate no of working hours

$
0
0

Hi Everyone,

I need to calculate no of working hours per day

I  have data as
StartTime                                         EndTime

1900-01-01 07:00:00.000    1900-01-01 15:00:00.000  
1900-01-01 15:00:00.000    1900-01-01 23:00:00.000   
1900-01-01 23:00:00.000    1900-01-01 07:00:00.000

I have tried with below query

DATEDIFF(hour,convert(time,starttime,112),convert(time,EndTime,112))

i am getting
8
8
-16

I need to get 8 for third record too.Why i am getting -16??

Please help me to solve this

Thanks in advance.....


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>