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

Hi ...

I need to calculate the age of a person from their date of birth (DOB). I have tried a few calculations from previous posts but have had no success, and not sure why.

I also need to know the number of days till their birthday .... I am not only after an answer to the calculation but the how and why, as I do not fully understand date calculations.

many thanks

Trevors

Here is a calculation that will work out the age:

NumToText(Year(Today) - Year(D.O.: - Case(Today< Date(Month(D.O.:, Day(D.O.:, Year(Today)), 1, 0))

This calculation will take the year of today and minus the year of the field which contains the users D.O.B

There is then a case statement where I have defined if Today is less than their birthday then minus 1 year off their age, if not minus 0 years.

If you need anymore clarification just post

Ed.

Eddy,

That's exactly where I'd change Today to Status(CurrentDate) unstored, or these ages would take some ages to recalculate everyday you open the db.

Try also this ....

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

Right! Think I'm getting it now,

Can I just check though!

If I had a button which when clicked it entered today's date and I did not want this date to change until the button was clicked again is it right that I would use Status(CurrentDate) stored?

But if i want to display today's date on the database I would use Status(CurrentDate) unstored, therefore the next day it would change - BTW I know I can use // for this but just as an example!

And always try to avoid using the Today Function as this has to recalculate each time the database is closed and reopened?

Thanks

Ed

Hi Trevors,

Take a look at Russ Baker's Handy Bits file in Sample Files. Don't take the first one, it was updated and you find the lastest version towards the bottom.

HTH

Lee

wink.gif

  • Author

Many thanks for this ..... I will check Russ Baker's Handy Bits, as I have a few more date calculations to do yet.

Again thanks

Trevors

Hi Trevors,

If you need anymore help with your dat calcs just come back and we'll sort you out

Ed

  • Author

Hi journeyman ....

Thanks for your help .... I have one more problem (for now anyway), I can not seem to work out where to start. I need to calculate the days until a persons birthday. I have a field DOB (Date Of Birth), and of course I have the Age field (The age of the person), but how do I calculate the days until the next birthday. I would like to work it out myself but do not know enough about Filemaker pro or programming. Could you please show me where to start, as I would still like to work it out as much as I can.

- DO you add the age (in years) to the DOB?

- Then count the current date to this date in days??

Like I said, I do not really know what I am doing, but enjoy working with Filemaker :-)

Trevor

ThingsOnline

Hi Trevor,

OK, first let me give you the new calculation to work out age, this is based on Ugo's post above, doing it this way will stop the need for FileMaker to work out the "Today" function as this can take a while - instead we have used the Status(CurrentDate) function.

NumToText(Year(Status( CurrentDate)) - Year(DOB) - Case(Status( CurrentDate)< Date(Month(DOB), Day(DOB), Year(Status( CurrentDate))), 1, 0))

Now, to work out how many days until their next birthday...

Firstly you need to know when their next birthday is. To do this create a new calculation field e.g. NxtBday. As you said you just want to know how to start as you would like to work out as much as you can, I won't give you the actual code but what you need to do is - Their date of birth plus their age in years plus 1 year. If you get stuck let me know and I will post the code for this.

Then all you need to do is what you said:

Their next birthday - Status(CurrentDate)

As I said if you need anymore help with the code, just post again and I'll be pleased to post the code required

Ed.

  • Author

Hi ....

Would it be correct to say

NxtBday=Date(Month(DOB), Day(DOB),Year( DOB)+Age+1)

This gives the date of the next birthday

NxtBday-Status(CurrentDate)

Days until next birthday

Trevors

Hi Trevor,

Yep, that's it!

Ed.

  • Author

Many thanks for your help

Trevors

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.