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.

Calculate age using current date problem

Featured Replies

I have a field that needs to calculate the age of an employee based on their birth date and the current date. Current date - birth date = age. Is there a way to make a field that contains the current date AND stays current? I feel like I'm missing something. This should be so easy, yet it's puzzling me.

Thanks,

Tom

Hi Tom, and Welcome to the Forums.

Not sure about v7, but the pre v7 would be like this.

birth date

  • Author

Hi Lee,

Thanks for the reply. I'm afraid you lost me on that. Right now, I have three fields defined for this: DOB (date of birth), Todays Date, Age. I have a script that gets the current date and puts it in the Todays Date field. Then I have Age set to calculate (Todays Date - D.O.B.) / 365 The answer comes out correctly, but I need a way to automate the Get Current Date script. Right now, I have to manually run the script from a button and then click once on the age field to get it to display the correct age. There must be a way to make this automatic. I don't want to do those steps each day on each record.

Thanks,

Tom

(Todays Date - D.O.B.) / 365 won't be valid for every day of the year for all years.

You don't need a Today's Date field. An unstored calculation using Get(CurrentDate) is all you need.

Year(Get(CurrentDate)) - Year(DOB) - (Get(CurrentDate)< Date(Month(DOB); Day(DOB); Year(Get(CurrentDate))))

As long as it's unstored and the result is set to be a number. You'll never have to mess with your age field again.

  • Author

I wish I understood what you just wrote. It sounds brilliant. I'm starting to feel quite simple. I'll have to try and figure out what that all means. I assume, that this is the text that would be inserted into the calculation. Could you explain it a bit more? Sorry to be so dense. I've been thrown in a little over my head. I'll sort it out, but it may take a while.

tom

Yes, this is the calculation to use in your Age field's definition.

You can break the calculation into two parts. The first part being Year(Get(CurrentDate)) - Year(DOB). This just subtracts the date of birth year from the current year. The second part tests whether today's date is less than the birthday for the current year. If it is true, then the result will be 1; if it is greater than or equal to this year's birthday, the result will be 0. This result is subtracted from the first part of the calculation to give the correct age.

This calculation is valid for every day of the year and accounts for leap years.

  • Author

Thanks you for the extra info. I'm going to try working with it a bit in the morning.

Thanks again.

Oops, I use the old term for Status(CurrentDate), you will need to replace it with the version 7 name for it, Get(CurrentDate) in order for the calculation to work.

The calculation that queue gave you will give you the age for years. The one that I provided gives you the years, months, and days.

Sorry,

Lee

  • Author

Queue and Lee,

Thanks so much for the help! It worked just like you said. That made my day (or even my week).

Thanks,

Tom

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.