Calculating No. of Days between 2 Dates In terms of Years, Months, Days

Version 2

    I Have created several Calculations to get the actual & expected result.

     

    Lets Take [Order_Date] and [Ship_date] are 2 date fields for this calculation purpose.

     

    [Order_Date]         [Ship_date]

    1-Jan-2014               21-Jan-2014

    21-Feb-2013             01-Jan-2015

    21-Mar-2013              12-Mar-2014

     

     

    Calculations :

     

    1) Years

    div( datediff('day', [Order_Date], [Ship_date] ), 365)

     

    2) We are deducting number years more than Order Date. (This is supportive Calculation)

    Name: Dateadd - Years

    dateadd( 'year', -[Years],   [Ship_date] )

     

    3) Months

    div( datediff('day', [Order_Date],[ Dateadd - Years]), 30)

     

    4) Days

    datediff('day', [Order_Date],[ Dateadd - Years])%30

     

    To get more details about this calculations & Report, go through the below link.

    https://public.tableau.com/profile/publish/DifferentBW2dates-YearsMonthDays-SampleDataBase-TableauSoftware/Sheet4#!/publish-confirm

     

    Limitations:This calculation treats 365 Days in Year, 30 Days in a Month.

     

     

    z1.PNG

    z2.PNG

    z3.PNG

    z4.PNG

    z5.PNG