# from birthday field, auto fill age field in years?

This topic is 7804 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

• Newbies

I'm designing a Client database that has a date field of the person's birthday. I also have an age field that I would like to be filled in auto as soon as I enter the client's birth date. I would like the age field to tell me how old they are in years. I know it is a calculation but having trouble configuring it. Help...thanks alot.

##### Share on other sites

Hi:

Define a calc field called age:

Year(Status(CurrentDate) - Year(Birthdate). Result should be a number.

Ken

##### Share on other sites

I prefer this formulation:

Age = Year(Status(CurrentDate)) - Year(Birthdate) - (Status(CurrentDate) < Date(Month(Birthdate), Day(Birthdate), Year(Status(CurrentDate))))

but you'll find many other formulations in past threads on these forums.

##### Share on other sites

Yes, yours is much more accurate.

Ken

##### Share on other sites

• Newbies

Thanks,

I will try them both and see which one works best for my situation.

Greg

##### Share on other sites

Make sure that you have chosen 'Do not store calculated results, calculate only when needed' or else the age calculated initially will remain the same and not update once a birthday has passed.

(Can someone with greater FM knowledge please confirm that this is correct !! Thanks)

##### Share on other sites

Hi Tom, unless you are triggering the field to force update the answer is yes:

the unstored calc will update otherwise you'll get age when first calculated

Dj

##### Share on other sites

Hi Brian!

Could you explain to me why you have two sides to this? I understand current year less birthday year ... but I don't understand what you are fine-tuning with ... LESS (current date LESS THAN (?) birthday date w/current year(?). Will this result in the number of additional days? Less than? Am I reading this wrong?

LaRetta

##### Share on other sites

Assuming that today is 12/09/2002 and that someone birthdate is 12/24/1969 than

Year(Status(CurrentDate)) - Year(Birthdate) would give 33

against

Year(Status(CurrentDate)) - Year(Birthdate) - (Status(CurrentDate) < Date(Month(Birthdate), Day(Birthdate), Year(Status(CurrentDate))))

which would give 32.

So the right way to use the formula should be=

Case(Sex="F",Year(Status(CurrentDate)) - Year(Birthdate) - (Status(CurrentDate) < Date(Month(Birthdate), Day(Birthdate), Year(Status(CurrentDate)))),Year(Status(CurrentDate)) - Year(Birthdate))

Dj

##### Share on other sites

Of course I'm only kidding

Don't test for sex when calculating age.

Dj

##### Share on other sites

Hi DJ!

How Funny!! Well, this DID throw me - thanks for explaining. So you only used the Case because of the Sex="F" portion? Is that also why you have the additional string at the end? Because Case needs a result (and it must be a number, right)?

Thanks for explaining the formulae, although I still don't understand why that '<' is there ... I'll work on it!

LaRetta

##### Share on other sites

Just subtracting the years tells you how old you will be this year, on or after your birthday. Until your birthday comes, you are still the age you turned last year.

Soooo, the simple subtraction of years tells us the age you will turn this year. Now we simply need to subtract one if you haven't yet had your birthday this year... that is, if today's date is before your birthday this year, then we need to subtract one.

Sooo, since true = 1 and false = 0, I simply subtract the result of that test. The expression:

(Status(CurrentDate) < Date(Month(Birthdate), Day(Birthdate), Year(Status(CurrentDate)))

returns 1 if I need to subtract 1 and 0 if I need to subtract 0. So, I just subtract it. Some might find this formulation more readable... I just find it longer:

Age = Year(Status(CurrentDate)) - Year(Birthdate) - If(Status(CurrentDate) < Date(Month(Birthdate), Day(Birthdate), Year(Status(CurrentDate))), 1, 0)

HTH.

##### Share on other sites

Oh Brian!

Thank you so much for explaining this to me! Now it makes total sense. I have trouble with formulas ... thinking them through in *real* words and you said it beautifully.

I appreciate all you give on this Forum! God, I love this Forum and FileMaker!

LaRetta

##### Share on other sites

This topic is 7804 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account