My start and finish columns are in the format ‘Yyyy-mm-dd HH:mm:ss.ms’ I want the difference between the two in HH:mm:ss.ms format. How do I go about this?
My query looks like this:
Select *,convert(time, Dateadd(s,
Datediff(s,
A.Finish,A.Start),
Cast('1900-01-01 00:00:00.000000' as datetime2)))as dif from(select *,dateadd(s,convert(int,left(start,10)),'1970-01-01') as Start,convert(int,left(finish,10)),'1970-01-01') as Finish from tableB)A order by dif asc
I’ve converted unix time stamps to standard format in inner query. When I run this the start date and start time appear as ‘2019-12-11 15:45:20.000’ and ‘2019-12-12 15:45:17.000’ but my dif appears as ‘00:00:03’