How do I create a formula that will give me the date a student turns 21 based on a Date of Birth Field
getasdate(Month(TABLE::BirthDate) &"/"& day(TABLE::BirthDate) &"/"& year(TABLE::BirthDate) + 20 21)
Edit: Typo, should be 21 as pointed out by others.
I'm sure there is a "correct" way to do this.... but I tried BIRTH + 7670.25 and it seems to work. ????
Steve's method is correct. FileMaker is excellent at maths!
You can add/subtract any part of the date (month, day, year) and the engine does wonders even with leap days and years.
Date ( Month(someDate) + 12 ; Day(someDate) ; Year(someDate) ), for example will give you the same day the next year. If this happens to be leap day? Well, just test it.
See my reply to this thread (actually, read the whole thread)
This is an easy one since you know it's the same day and month, just 21 years from the birthday (not 20). No leap years to worry about (though any date API will take care of those for you).
If you're born in January 1, 2000, you're zero years old not 1 year old already (hey, it's your birthday after all). You're not 1 year old until January 1, 2001.
So, Java, via a micro-service has an elegant and easy to use Date API.
For example, in this case, all you would need is one super-simple (easy-to-read) line of code, like this (note "plusYears()" is built in to the API):
You're zero years old on your birthday, so shouldn't you be adding 21, not 20 as in your reply above?
No, not a great idea, IMHO, to use magic numbers.
In this OP's case, use year offsets and use FMP's (or other API) built-in date math.
Otherwise, special cases can start popping up.
Why not use the Date( ) function that actually returns a date?
Let ( dob = Table::BirthDate ; Date ( Month ( dob ) ; Day ( dob ) ; Year ( dob ) + 21 ) )
Why not use the Date( ) function that actually returns a date? Let ( dob = Table::BirthDate ; Date ( Month ( dob ) ; Day ( dob ) ; Year ( dob ) + 21 ) )
Because I'm not as smart as you ...and I'll never be
Retrieving data ...