I have this time-duration: 00:00:23.323
I want to convert it in sql to milliseconds.
EDIT:// I tried this but it isn't very nice:
SELECT (DATEPART(hh,'12:13:14.123') * 60 * 60 * 1000) SELECT (DATEPART(n,'12:13:14.123') * 60 * 1000) SELECT (DATEPART(s,'12:13:14.123') * 1000) SELECT DATEPART(ms,'12:13:14.123')
How does it work?
Thanks for your answers.
We can use DATEPART() function to get the MILLISECOND part of the DateTime in Sql Server, here we need to specify datepart parameter of the DATEPART function as millisecond or mi .
MySQL CURDATE() Function The CURDATE() function returns the current date. Note: The date is returned as "YYYY-MM-DD" (string) or as YYYYMMDD (numeric).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With