Jump to content
Server Maintenance This Week. ×

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

Recommended Posts

Attached is a fairly simple way to search for people by age using multikey relationships. I needed a way to do this in an application I am working on as my users will not be bright enough to work out the dates themselves. Originally I simply multiplied the age number by 365.24 and subtracted from the date but was not entirely happy with the results. The tricky part was working around leap years and different system settings. The attached calculations should work regardless of the system setings and occurances of Feb 29. If the multikey is required to fall on Feb 29 for a year that has no leap year it is changed to Feb 28. The calculation is designed to find real people by age so it limits the max range from 1/1/1800 to 1/1/4000 (filemakers max date). I have referenced the test date field so you can see how it performs around leap years by changing the date. For real world use change all references to the test date field with Get( CurrentDate ). It took me a couple of hours to get the calculations to function properly and there may well be an easier way but it is here if anybody wishes to use it.

Dates.zip

Link to comment
Share on other sites

Comment,

I certainly found the long way around, didn't I. I never even considered that FM would automatically go to 1/3 if 29/2 did not exist. I assumed it would produce an invalid date and an error. I will leave the limit dates as these are two of 17 multi key fields and they should not be required to contain data to show records in the portal. I imagine FM will have a new version by 4000!

Link to comment
Share on other sites

Yes, the Date() function is very powerful because of that, and calculations that are seemingly complex can be made very simply, e.g. Date ( Month + 1 ; 0 ; Year ) returns the last day of the Month in that Year.

Vaughan, version 7 added another millennium and goes up to Dec 31, 4000.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

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