Reputation: 79
I'm having some problems converting minutes to a decimal even though I've looked at other responses at SO.
select cast(datediff(minute, min(start_time), min(complete_time)) as decimal (10,10))
from TRACKED_OBJECT_HISTORY TOH1
where TOH1.op_name = 'Assembly'
The result returns, but I always get results like 2.00, 4.00, 5.00 instead of numbers like 1.86, 3.99, 5.03. I guess it's converting after the fact (I also tried the convert function to no avail). Any thoughts?
Upvotes: 4
Views: 9907
Reputation: 1269503
Datediff return an integer, not a float or numeric.
To get what you want, perhaps you should do the diff in seconds and then divide:
select cast(datediff(second, min(start_time), min(complete_time))/60.0 as decimal (10,10))
from TRACKED_OBJECT_HISTORY TOH1 where TOH1.op_name = 'Assembly'
Upvotes: 7