Calculating an age from a birth date



Help needed!!

How can I use a date of birth to show as a persons age?


CurrentYear - BirthYear = Age.

Ok, less snarky: Age to the day? To the month? To the year? The minute? What’s the input for their birthday look like? Are they inputting Day/Month/Year? Just Year? Lunar months since birth?


Hahaha! Thank you! I was way over thinking it. :slight_smile:


You can get a little more advanced if you like. If you use something like this:

[[Math.floor((Now.valueOf() - Date.parse('02/28/1989').valueOf()) / 1000 / 60 / 60 / 24 / 365)]]

For example this will give 28 years before Feb 28 and 29 years after Feb 28, if you want to account for whether we’ve passed their birth date or not in the year. It’s not perfect as it doesn’t account for leap years but it’s probably good enough.

(Note the American mm/dd/yyyy date format in the .parse method)


Hello there.

Let’s say the respective date has to be entered in a text input formfield or be picked from the variables. How do I point this function to parse that date instead of the predefined, static 02/28/1989 ?

Thanks for your advice…


… already got it. Had a bug that confused me :confused:


For anyone else wondering, you would replace the static date in the expression with a variable that you would then set when someone typed in a date into a text field.