Jump to content

from birthday field, auto fill age field in years?


This topic is 7899 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.

Link to comment
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.

Link to comment
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)

Link to comment
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? confused.gif Less than? Am I reading this wrong?

LaRetta

Link to comment
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

Link to comment
Share on other sites

Hi DJ!

grin.gif 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! wink.gif

LaRetta

Link to comment
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.

Link to comment
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! smile.gif

LaRetta

Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.