Calculate age on a certain date in the future based on DOB field (Job Request) [RESOLVED]

Dears,

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.

Regards.

Hello,

I would be glad to assist you.

To discuss further in detail kindly reach me at garry@cisinlabs.com or Skype me: cis.garry

Looking forward for your response.

Thanks

Garry

Hi,

Dario from Gravity Wiz here 🧙‍♂️.

My understanding is that Gravity Forms Date Time Calculator - Gravity Wiz would work out of the box without further customization.

You would need to subtract the DOB from the future date and set the rounding to at least 1 space and it will return a number like 7.8.

If you need something like 34 Years, 11 months and 20 days that can be doable with this tutorial: How to Populate and Modify Dates and Times with Gravity Forms - Gravity Wiz, Gravity Forms Populate Anything - Gravity Wiz Live Merge Tags and a HTML field.

I hope this helps!

Best,

I posted our solution in the other thread for this, but I wanted to post it here also.

We came up with a solution that uses Populate Anything and a snippet that adds diff merge tag modifiers.

David made a video walking through how everything works.

And here’s the snippet. Just copy and paste this into your theme’s functions.php file.

2 Likes

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.

Hello Scott,

Thank you all for your hard work and effort. It works great out of the box. Thank you once more.

Regards.

Hi Krystal,

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

Regards,
Ahmed

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.

© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.