Hi SQL Gurus, I can't seem to find the answer to this simple problem. I am trying to convert a datetime to a numeric(5,2). I only want the minutes converted. Here is my date:1899-12-30 08:30:00.000 Here is my attempt: CAST(DATEPART(minute, HC_ApptDetail.TimeFrom) / 60 AS numeric(5, 2)) AS starttimeM_t The result: 0.00 it should be 0.50 What am I missing?
Even though you are later casting to a decimal type, SQL Server is returning an integer from your division because both the numerator and denominator are integers. Then it is simply casting that integer to your desired data type. If you change "60" to "60.0", you will get the answer you want.