I know that you indicated that you want to compare the time of day (get the decimal part), but since the title is how to convert DateTime to Decimal, here's how to get an integer numeric value in one (integer and decimal parts). You can do the following (VB.NET) and it will be equivalent to SQL Server:
Dim TimeZero As New DateTime(1900, 1, 1) Dim MyTime As DateTime = DateTime.Parse("2012-07-27 08:29:20.000") Dim DecResult As Decimal = DateDiff(DateInterval.Day, TimeZero, MyTime) + (MyTime.TimeOfDay.TotalSeconds / (24*3600))
source share