I need to create a function in SQL that returns employee's time, for example: years , months and days
So far I've been able to bring the years and months , but I could not reach the day's logic yet, / p>
DECLARE @DTINI DATE, @DTFIM DATE
SET @DTINI = '2015-12-17'
SET @DTFIM = '2016-03-10'
SELECT CAST(DATEDIFF(DAY,@DTINI,@DTFIM)/365.25 AS INT) ANOS,
CASE WHEN DATEDIFF(DAY,@DTINI,@DTFIM)/30 > 11 THEN 0
ELSE DATEDIFF(DAY,@DTINI,@DTFIM)/30 END MESES