We have a school admission form that shall calculate applicant age by certain date in the future (01/10/2022) for example based on his/her DOB field. The age should be very accurate to include years - months - days.
For example: if DOB is (25/11/2014) then his calculated age by (01/10/2022) should be (7 years 10 months 6 days)
I used this website to calculate the age in the above example: Age Calculator
GP Date Time Calculator is not accurate it just shows me number of years so the result for the above example using this plugin will be (8 years).
So is there a way to get this done. Please let me know the time frame and expect cost for that.
Hi there.
Thanks so much for this super useful snippet. I am a school creating a registration form as well.
I don’t know if I am creating the merge tag correctly. The value isn’t returning properly.
This is my merge tag.
Birthdate is the admin label. The date field ID is 17.
@{Birthdate:17:diff[2022-01-09],format[m]}
I am getting values of 7 and 4 for birthdates entered in 2017 or 2019 and neither of those are correct so I’m not sure what is wrong.
It did return the correct year but when I changed it to months (which I need for accuracy) it failed to return a correct result. Also it doesn’t appear to be changing dynamically when the date is changed in the field.
I think you need to re-watch the video posted by Scott. You will use three merge tags to views the age at (2022-01-09) YYYY-MM-DD
Age in Years: @{Birthdate:17:diff[2022-01-09]}
Age in Months: @{Birthdate:17:diff[2022-01-09],format[m]}
Age in Days: @{Birthdate:17:diff[2022-01-09],format[d]}
Those there will give you applicant date on (2022-01-09) so the final result will be something like that on (2022-01-09) applicant will have 2 years 1 months 15 days
Right.
Well thank you I do appreciate you getting back to me.
That is a clunky and ugly solution to this problem that doesn’t look nice enough for my purposes. Glad it solved your problem Ahmed.
I’ll look elsewhere to find someone to code something cleaner.