To get the difference between two dates, we can use
DATEDIFF(YY, '01/24/1977', GETDATE()) AgeInYears,
DATEDIFF(MM, '01/24/1977', GETDATE()) AgeInMonths,
DATEDIFF(DD, '01/24/1977', GETDATE()) AgeInDays
Passing first parameter as different interval values, we can get year, month and days. Here, the SQL query will return difference of two dates in year, month an days respectively.
Views: 4165 | Post Order: 76