When I use a DateDiff
in a SELECT
statement in SQL Server, I get an int
value back:
select DATEDIFF(day,'01/01/2011','15/05/2011')
from Table1
Result is : 134
select DATEDIFF(day,'01/01/2011','15/05/2011')/15
from Table1
Result is : 8
select cast(DATEDIFF(day,'01/01/2011','15/05/2011') / 15 as Decimal(9,2))
from Table1
Result is : 8.00
But in reality the result is : 8.9333333
How can I change the result from int
to Double
?
I want to get the result 8.9333333
- how can I do this?