So I donβt know how to subtract two time(hh:mm:ss) in sql server.
time(hh:mm:ss)
This is my statement:
where ( CONVERT(TIME(7), [EndWork], 102)) - ( CONVERT(TIME(7), [StartWork], 102)) < CONVERT(TIME(7), ' 8:30:00', 102)
DECLARE @END_DATE TIME = '' , @START_DATE TIME = '' SELECT CONVERT(TIME,DATEADD(MS,DATEDIFF(SS, @START_DATE, @END_DATE )*1000,0),114)
Using the DATEDIFF function, you will get the difference of two dates / times in the year / month / day / hour / min / sec, as you require.
For example: - DATEDIFF ( MINUTE , startdate , enddate ) - will return diff in minutes
DATEDIFF ( MINUTE , startdate , enddate )
You can try using the DATEDIFF function as follows:
where DATEDIFF(HH,StartWork, EndWork)
You can simply call a query like:
SELECT CONVERT(varchar,(EndWork- StartWork), 108) FROM tablename
The output returns the format (hh:mm:ss) .
(hh:mm:ss)