Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert DateTime to a number with a precision greater than days in T-SQL?

Both queries below translates to the same number

SELECT CONVERT(bigint,CONVERT(datetime,'2009-06-15 15:00:00'))
SELECT CAST(CONVERT(datetime,'2009-06-15 23:01:00') as bigint)

Result

39978
39978

The generated number will be different only if the days are different. There is any way to convert the DateTime to a more precise number, as we do in .NET with the .Ticks property?

I need at least a minute precision.

like image 526
Jader Dias Avatar asked Jun 15 '09 18:06

Jader Dias


1 Answers

SELECT CAST(CONVERT(datetime,'2009-06-15 23:01:00') as float)

yields 39977.9590277778

like image 58
D'Arcy Rittich Avatar answered Oct 20 '22 15:10

D'Arcy Rittich