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

Posted by Jader Dias on Stack Overflow See other posts from Stack Overflow or by Jader Dias
Published on 2009-06-15T18:11:28Z Indexed on 2010/03/08 2:12 UTC
Read the original article Hit count: 303

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.

© Stack Overflow or respective owner

Related posts about sql-server-2005

Related posts about tsql