11 Replies Latest reply on Nov 30, 2015 6:37 AM by user19752

# age calculation

!@I'm trying to use a calculation to determine age. I'm using the formula If (Date of Birth=1/1/2015;"0"; (Today's Date-Date of Birth)/365.25)

When I enter 02/17/1941 the age shown is 73 incorrect by one year. What am I doing wrong?

• ###### 1. Re: age calculation

Try this:

Let ( [

_agedate = GetAsDate ( Get ( CurrentDate ) + 1 - DOB ) //the + 1 because date starts at 1/1/0001

] ;

//Year ( _agedate ) - 1 //if you only need the years

Year ( _agedate ) - 1 & " years, " & Month ( _agedate ) - 1 & " months, " & Day ( _agedate ) - 1 & " days"

//for age in years, months, days, Because months differ in length, the result can be slightly wrong in days, but not in years

)

regards

Otmar

• ###### 2. Re: age calculation

Read through this thread. There is simply no reason to use a calculation that you know will at some point come up with an incorrect answer.

Both the calculation I posted and the one erolst posted work great. I have not seen any dates yet that have broken the calcs.

Age calculation from DOB

• ###### 3. Re: age calculation

I remember for a long time being annoyed at FileMaker for not having an "Age" calculation since so many of us have to figure this calculation out and as simple as it is to say, it actually is a bit hard to calculate.  Of course I see things through the eyes of an American developer in Dallas Texas who sometimes isn't as aware of the world as I would like to think I am.  Anyway, at one point, I started dating a lovely lady, and FileMaker developer, from China.  Fun story is that I actually first met her at a Devcon.  But that aside, I found out something very interesting in dating her.  Not all of the world calculates age like us Americans and an Americanized "Age" calculation would conflict with some other cultures understanding of age.  For Example, in China, you start out at age one when you are born because that is your first year.  When you have completed your first year, you are now two and not one like us Americans calculate.  But one of the real benefits that my girlfriend had was that when US Customs asked her about her age, they informed her she miscalculated and was really a year younger.  Well, not really, but at least the American calculation was a year younger and she really liked that.  Anyway, this lets me realize there actually is a reason why there is not an "Age" calculation in FileMaker at least the way I would have expected it to be with my narrow view of the world.

• ###### 4. Re: age calculation

This is a calculation of the age in days, months and years

You can choose what you want

Let (

[

Date of Birth = Date of Birth ;

ZDate = Get ( CurrentDate ) ;

years =Year ( ZDate  ) - Year ( Date of Birth ) - If ( ZDate  < Date ( Month ( Date of Birth ) ; Day ( Date of Birth ) ; Year ( ZDate  ) ); 1 ; 0 ) ;

months = Mod ( Month ( ZDate  ) - Month ( Date of Birth ) + 12 - If ( Day ( ZDate  ) < Day ( Date of Birth ) ; 1 ; 0 ) ; 12 ) ;

days = Day ( ZDate  ) - Day ( Date of Birth ) + If ( Day ( ZDate  )  ≥ Day ( Date of Birth ) ; 0 ; If ( Day ( ZDate  - Day ( ZDate  ) )  < Day ( Date of Birth ) ; Day ( Date of Birth ) ; Day ( ZDate  - Day ( ZDate  ) ) ) ) ;

full =

GetAsText ( Year ( ZDate  )  - Year ( Date of Birth) -

If ( ZDate  <  Date ( Month ( Date of Birth) ; Day ( Date of Birth) ; Year ( ZDate  ) ) ; 1 ; 0 ) ) & " y " &

GetAsText ( Mod ( Month ( ZDate  ) - Month ( Date of Birth) + 12 - If ( Day ( ZDate  ) < Day ( Date of Birth) ; 1 ; 0 ) ; 12 ) ) & " m"

]

;

full

)

• ###### 5. Re: age calculation

Thank you. Works like a charm!

Rich

• ###### 6. Re: age calculation

Do you allow the result 1 for dob is 12/1/2015 on 11/30/2016 ?

• ###### 8. Re: age calculation

I use this formula which works pretty well for my situation

Year ( Get ( CurrentDate ) ) - Birth Date Year- If ( Get ( CurrentDate ) < Date (Birth Date Month ; Birth Date Day ; Year ( Get ( CurrentDate ) ) ); 1 ; 0 )

• ###### 9. Re: age calculation

Thanks, Tom

Sent from my iPhone

• ###### 10. Re: age calculation

user19752 wrote:

Do you allow the result 1 for dob is 12/1/2015 on 11/30/2016 ?

In this case, my formula gets the result: 0 y 11 m 29 d

• ###### 11. Re: age calculation

It is logical.

By the way, Japanese law say 1 for the days on some cases. I think it is crazy...

And, there is another counting of age in Japanese, 'kazoe doshi', starting 1 at born, count up on every January 1 everyone. So, a man born on December 31, he become 2 years old on next day