5 Replies Latest reply on Jun 6, 2014 12:57 PM by Prashant Sharma

# Date difference for DOB

Hi All,

I am trying to calculate age and facing some issues

DATEDIFF( ‘year’, [Date of Birth], TODAY())

However when I see the results they are getting rounded

Example: when the users age is 28years1month its showing as 28 years same when we have difference in days

so I am trying to get exact age with years month and days

May be something like this in Excel I believe which I found online

=DATEDIF (E1, TODAY( ),"Y") & " Years, " & DATEDIF (E1, TODAY( ),"YM") &

" Months, " & DATEDIF (E1, TODAY( ),"MD") & " Days"

Thanks,

Praveen

• ###### 1. Re: Date difference for DOB

Thanks,

Praveen

• ###### 2. Re: Date difference for DOB

Hi

I want to display exact age of user

Example:

Name   DOB (yyyy-mm-dd)   Age

a         1947-06-02         67 Years 0 Month/s 4 Days

b         1947-07-10         68 Years 10 Month/s 27 Days

c         -----------        -----------------------

Thanks,

Praveen

• ###### 3. Re: Date difference for DOB

Hi Praveen,

Check the attached file. Here I have used following formula -

str(DATEDIFF('year',DOB, today()) - (IF (DATEADD('year', DATEDIFF('year', DOB,today()),

DOB)) >  today()

THEN 1 ELSE 0 END))+' year, '+

str(MONTH(date(today()-(DATEADD('year', DATEDIFF('year', DOB, today()), DOB)))) - 1)

+' month, '+

str(DAY(date(today() - (DATEADD('year', DATEDIFF('year', DOB, today()), DOB)))) - 1)

+' days'

Warm Regards,

Prashant Sharma - India | LinkedIn

• ###### 4. Re: Date difference for DOB

Hi Prashant,

Thanks a lot for your help with explanation

This works for me

Regards,

Praveen

• ###### 5. Re: Date difference for DOB

Glad to know that it helped!

PS - Always search for SQL formulas for these type of calculations & try to relate those with Tableau calculations. This will always help you.

Warm Regards,

Prashant Sharma - India | LinkedIn