Binu, you made a good point. The code should be modified as follows:

DECLARE
@startdate datetime,
@enddate datetime,
@years int,
@months int,
@days int

SET @startdate = CONVERT(datetime, '20040203')
SET @enddate = CONVERT(datetime, '20050104')

SET @years = YEAR(@enddate) - YEAR(@startdate)
SET @months = MONTH(@enddate) - MONTH(@startdate)


IF DATEADD(yy, @years, @startdate) > @enddate
BEGIN
SET @months = DATEDIFF(m, DATEADD(yy, @years -1, @startdate), @enddate)
SET @years = @years -1
END

IF DATEADD(m, @months, DATEADD(yy, @years, @startdate)) > @enddate
BEGIN
SET @days = DATEDIFF(d, DATEADD(m, @months -1, DATEADD(yy, @years, @startdate)), @enddate)
SET @months = @months -1
END
ELSE
BEGIN
SET @days = DATEDIFF(d, DATEADD(m, @months, DATEADD(yy, @years, @startdate)), @enddate)
END

SELECT 'Years:', @years
SELECT 'Months:', @months
SELECT 'Days:', @days