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.

Featured Replies

  • Newbies

Does anyone know of the simplest way to calculate age in years? I have a field called "Birthday." Year(Today-Birthday) does not work... I have longer, complicated solutions, but am I missing some simple function?

I would be happy to know of any web sites or books that archive common calculation solutions... or maybe this is the place!

Thanks, Chuck

Almost got it Chuck, try

Year(Today)-Year(Birthday)

with the result being a number. Note that this may not give the correct result if the Birthday is after the Today date as it is only looking at the year component of the dates.

You could also try

(Today-Birthday)/365.25

with the result as a number. This will give a more accurate age for the individual.

Keep in mind the problems inherent in using the Today function (recalculation time, refreshing function), especially on large databases.

  • 3 weeks later...

I had a similiar problem with my student database and successfully implemented a solution I located on the www:

NumToText(Year(Today) -Year(DOB) - Case(Today<Date(Month(DOB), Day(DOB),

Year(Today)), 1, 0)) &

  • 3 weeks later...

Here's yet another solution.

You need three fields

Today's Date

Birth Date

Age

Use the formula

Age=(Today's Date-Birth Date)/365

This calculation gives you the number of days between today's date and the birth date. So when you divide it by 365 you get the number of years. There is a drawback to this calculation as well. It does not take into account for leap years.

------------------

Ryan

[email protected]

  • 1 month later...

This will give you everything. Create four fields. 1.Date of Birth Field.

2. Age Year

3 Age Month

4. Age Day

The last three are calculation fields that will give you your age by year, month and day by copying in the calculations below.

CALCULATION FOR YEAR:

Year(Today) - Year(DOB 1) - If(Today< Date(Month(DOB 1),Day(DOB 1),Year(Today)),1,0)

CALCULATION FOR MONTH:

Mod(Month(Today) - Month(DOB 1) + 12 - If(Day(Today) < Day(DOB 1),1,0),12)

CALCULAITON FOR DAY

Day(Today) - Day(DOB 1) + If(Day(Today) >=

Day(DOB 1),0,If(Day(Today- Day(Today)) <

Day(DOB 1),Day(DOB 1),Day(Today- Day(Today))))

If you only want the year, place only that field on your layout. Good Luck

------------------

Bob Sherman

[email protected]

  • 2 weeks later...

Why don't people use the Status (CurrentDate) and Status(CurrentTime) instead of the Today function?

  • 1 year later...
  • Newbies

This solution builds on the one of birdman, above. Thanks for the tip. This one goes one step further by limiting the result to the first two digits of the calculation. It works fine as long as the person is not over 100 years old.

You only have to create a "Birthday" field (as a "date" type) and an age calculation field using this formula:

left ((Today - Birthday) / 365.25, 2)

To increase the calculation to include ages over 100, do this:

left ((Today - Birthday) / 365.25, 3)

In this case, people less than 100 will look something like "45.", while those over will look fine.

I tend to dislike any date calculation that uses hard-coded values like 365.25 because by design they won't be accurate. With thought, ways can be discovered to do the task that involve only FMP's built-in date functions.

Year(Status(CurrentDate)) - Year(birthday) -

Case(Month(Status(CurrentDate)) < Month(birthday), 1,

Month(Status(CurrentDate)) = Month(birthday),

If(Day(Status(CurrentDate)) < Day(birthday), 1, 0),

0)

It could even be extended to working out the age down to birth time as well for extra accuracy: I'll leave that as an exercise.

Hello Chuck;

Simple solution:

- Create a new DATE field

  • 5 months later...

Bob,

I tried this calculation using "DOS" which is my Date of Service in place of current date and it didn't work. I get an error message that "DOS" is not a valid status flag. Any ideas?

What I am trying to do is just what you did but rather than using the current date off my computer, I want to use a date I select because the service may have been done a few days ago or even 5 years ago. Thanks, Carlo

I've been using one like this for a long time now working on medical records databases:

Enter the actual date of birth in

field(date): [color:"green"] person.ageDateOfBirthEntry

Calculation(number) field: [color:"red"]person.AgeCurrent =

Truncate( (Status(CurrentDate) - [color:"green"]person.ageDateOfBirthEntry)/365, 0)

If you want to capture the person's age at a particular point in time/event, then change the "Status(CurrentDate)" to the date of the event. Otherwise, the persons age will always reflect their age at the current moment in time.

I tried this calculation using "DOS" which is my Date of Service in place of current date and it didn't work. I get an error message that "DOS" is not a valid status flag. Any ideas?

You need to replace all of "Status(CurrentDate)" with "DOS". Do NOT write "Status(DOS)". Here is my recommended age calculation:

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

which for you would become:

Year(DOS) - Year(Birthdate) - (DOS < Date(Month(Birthdate), Day(Birthdate), Year(DOS)))

HTH.

  • 4 weeks later...

The beauty of FM is that I simply copied the text that Kennedy posted into my Age field definition (after creating a Birthdate field). I had an Age field fully functional in less than 30 seconds. I appreciate the ease of FM now that I am taking C++ and Access in college.

Ken

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.