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

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........