Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

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

Posted

Hi Tom, and Welcome to the Forums.

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

birth date

Posted

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

Posted

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

Posted

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

Posted

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.

Posted

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

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