Note :
Take a look and explore some examples of DATEDIFF functions in SQL Server.
SELECT DATEDIFF(year, '2019/04/28', '2021/04/28');
Result: 2
SELECT DATEDIFF(yyyy, '2019/04/28', '2021/04/28');
Result: 2
SELECT DATEDIFF(yy, '2019/04/28', '2021/04/28');
Result: 2
SELECT DATEDIFF(month, '2019/01/01', '2019/04/28');
Result: 3
SELECT DATEDIFF(day, '2019/01/01', '2019/04/28');
Result: 117
SELECT DATEDIFF(hour, '2019/04/28 08:00', '2019/04/28 10:45');
Result: 2
SELECT DATEDIFF(minute, '2019/04/28 08:00', '2019/04/28 10:45');
Result: 165
Previous lesson: CURRENT_TIMESTAMP function in SQL Server
Next article: DATEADD function in SQL Server