gopi nath pandraju gopi nath pandraju - 20 days ago 10
SQL Question

Days between two dates In SQL Server

I am using

DATEDIFF(d, @Date, @ExDate) as T


to get the number of days between
@Date
and
@ExDate
. I got the number of days. But I want to the fraction T/365 for some calculation. If I do this I got 0 because it returns the time. What should I do to get that value?

Answer

Try This:

SELECT ( DATEDIFF(DAY, '2016-11-12', '2016-11-30') ) / 365.00
Comments