I am working on a database for a school. Admin enters the birthday and calculation enters how old they are, but what do I need to do so the how old they are updates everyday?
make a calculation field type instead of a number field type.
Have the result of the calculation be numeric
Use an age calculation to determine age based on birthdate.
Set storage to "unstored", or "create indexes when needed".
thanks, had it as text, number fixed it, thank you!
Pretty close, but only unstored will work, not unindexed.
As an aside, I'd be interested to know how you're calculating the age - I've tried a couple of custom functions, none of which have proved entirely accurate, especially where leap years are concerned.
I use winfried's CF most of the time:
It's accurate for leap years as far as I've experienced.
This one is a little simpler and appears to work okay for leap years (at least on a casual test):
Let ( [ todaysDate = Get ( CurrentDate ) ; DOB = GetAsDate ( BirthDate ) ] ;
Year ( todaysDate ) -
Year ( DOB ) -
todaysDate < Date (
Month ( DOB ) ;
Day ( DOB ) ;
Year ( todaysDate )
Mike - Thanks - I've tried that one before, but have problems with it - see below. Probably my error, but I can't see what I'm doing wrong.
Do you have the dates in the wrong order?
No, I checked that. There are enough people happy with this for me to be sure that it's my error, but I really can't see it.
PS - I wonder why FM doesn't have a native age calc function?
Thanks Mike. Yes, a lot simpler, with the obvious limitation that it returns only the year value, but looks useful for my purposes - thanks very much.
Sorry; missed the part about needing finer granularity. But glad it works out.
You may want to take a look at <http://fmdiff.com/fm/agecalc.html>.
Retrieving data ...