Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

from birthday field, auto fill age field in years?

Featured Replies

  • 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.

Hi:

Define a calc field called age:

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

Ken

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.

Yes, yours is much more accurate.

Ken

  • Author
  • Newbies

Thanks,

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

Greg

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)

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

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

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

Of course I'm only kidding crazy.gif

Don't test for sex when calculating age.

Dj

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

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.

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.