• Thanks for taking the time to create and share your code. I found that when the @FromDate was more recent than the @ToDate the returned answer was incorrect. I simplified your script and corrected this issue. Thanks again.

    Lee

    Here is the modified script:

    CREATE Function [dbo].[fn_TotaltimeBetweendates] (@Fromdate datetime, @Todate datetime )

    Returns nvarchar(40)

    as

    Begin

    RETURN

    (

    SELECT

    CAST(Years AS VARCHAR(4)) + ' Years :' +

    CAST(ABS(Months) AS VARCHAR(2)) + ' Months :' +

    CAST(ABS([Days]) AS VARCHAR(2)) + ' Days'

    FROM

    ( -- f

    SELECT

    Years,

    Months,

    [Days] = DATEDIFF( DAY,DATEADD(MONTH,Months,DATEADD(YEAR,Years,@Fromdate)),@Todate)

    FROM

    ( -- e

    SELECT

    Years,

    [Months] = DATEDIFF(MONTH,DATEADD(YEAR,Years,@Fromdate),@Todate)

    FROM ( -- d

    SELECT

    [Years] = DATEDIFF(YEAR,@Fromdate,@Todate)

    ) d

    ) e

    ) f

    )

    End