SQL convert time to milliseconds SQL convert time to milliseconds sql sql

SQL convert time to milliseconds


Use DATEDIFF:

SELECT DATEDIFF(MILLISECOND, 0, '00:00:23.323')

Result:

23323


You can use datepart function. like this

select DATEPART(MILLISECOND,GETDATE())+DATEPART(second,getdate())*1000


I got it, it isn't the nice way but it works:

SELECT (DATEPART(hh,'00:00:23.323') * 60 * 60 * 1000) + (DATEPART(n,'00:00:23.323') * 60 * 1000) + (DATEPART(s,'00:00:23.323') * 1000) + DATEPART(ms,'00:00:23.323') AS 'DurationInMillis'