Issue in subtracting 2 times , i need to get result in hh:mm:ss format
hi guys,
this query
select convert(varchar(12), dateadd(ms, datediff(ms,'24:00' , '27:1' ), 0), 114)
i facing error : conversion failed when converting date and/or time character string.
i need result in hh:mm:ss format
please me out on issue.
thank you,
arjun.
arjun,
the error comes '24:00' & '27:1'. must date or time types.
here's solution:
declare @start time; declare @end time; declare @null time; set @start = '09:06:00'; set @end = '21:27:00'; set @null = '00:00:00'; select convert(varchar(8),dateadd(ms, datediff(ms, @start,@end ), @null), 114)
this solution inspired link:
https://social.msdn.microsoft.com/forums/en-us/5a259b55-a2aa-4c3c-a73d-afa44d455f5c/difference-between-2-time-columns-in-sql-server-2008?forum=transactsql
please click "mark answer" if post helped.
SQL Server > SQL Server Express
Comments
Post a Comment