Programming language used to interact with SQL Server databases
Hi @Bobby P
As documented here: DATEDIFF (Transact-SQL)
This function returns the count (as a signed integer value) of the specified datepart boundaries crossed between the specified startdate and enddate.
Therefore, the result is right.
If you want decimal results in years, try this:
SELECT CAST(DATEDIFF(D,'2023-12-31 08:31:42.373', '2024-03-28 08:30:42.373')/365.25 AS DECIMAL(10, 2))
Best regards,
Cosmog Hong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".