In SQL Server(T-SQL) you can convert a DateTime variable to a a decimal values like this:
CONVERT(DECIMAL(20,10),@mytime)
Sample Input: 2012-07-27 08:29:20.000
Sample Output: 41115.3537037037
Is there any equivalent method of converting a DateTime in .NET(C# or VB) to the same type of decimal?
I am looking to compare times on different days.
Calculating
41115.3537037037 % 1 = .3537037037
This would allow me to easily compare times on different dates.
It looks like this is “number of days since 1st January 1900”. In which case, you’d use: