I have the following two column with Time values
;WITH cte AS (
SELECT *
FROM (VALUES
('08:00:00','18:30:00'),
('20:00:00','08:00:00'),
('18:30:00','06:00:00'),
('08:00:00','18:30:00')) as t(time1, time2)
)
How can I get the following difference values:
result
10.5
12
11.5
10.5
I tried with DATEDIFF but I am never able to get a true values especially for the case from 18:30 to 6:00 I tried like this, but does not work for this case(8:30 to 6:00) ...
CASE
WHEN GirisSaati > CikisSaati THEN cast( DATEDIFF(MINUTE, cast(CikisSaati as time ), cast(GirisSaati as time ))as float) / 60
WHEN GirisSaati <= CikisSaati THEN cast( DATEDIFF(MINUTE,cast( GirisSaati as time ), cast(CikisSaati as time ) )as float) /60
END
Hope to find help, thanks ...