gopi nath pandraju gopi nath pandraju - 1 year ago 124
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
. 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 Source

Try This:

SELECT ( DATEDIFF(DAY, '2016-11-12', '2016-11-30') ) / 365.00
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download