Ian C0ckcroft (2/18/2013)
Hi guys, I am trying to calculate the diffs between to days as a decimal. The hours will an easier wayybe in decimal.i can do it in varchar, but i need to be able to agrigate my value.
eg.
datediff(DD, [CreatedOn],getdate()) + CAST(DATEPART(HH, GETDATE())- DATEPART(HH, [CreatedOn]) AS REAL)/10
this gives me the results i need.
is there an easier way?
Why are you dividing the difference in hours by 10? I'm guessing that's supposed to be 24 with a conversation to a float or decimal type.
Either way I think this is what you are looking for
Declare @create_date datetime = '1/1/2013', @execution_date DATETIME = GETDATE();
SELECT CAST(@execution_date - @create_date AS REAL)