How can I calculate user age by his birthday date?

Stay safe.

How can I calculate user age by his birthday date?

Stay safe.

I’m sorry but none of the solutions worked for me. It seems they don’t take into account the leap years.

To me the solution was to emulate what you do in real life:

- you look at the year of birth and make the difference with the current year
- then you check whether the current day of the year is higher than the birth day of the year, and decide to subtract 1 or not

Here is the formula (i’m using a date / time picker):

Hope it helps someone!

Don’t forget about Leap years…

When you do ‘Current Date time’ - ‘Birth date’:format as days, it will result in the total amount of days, counting leap years (366 days). So if you want to get closer to the real age, you should divide by 365.25

If you want to get perfect calc, you then need to value how many leap years were there during the total period, subtract, and than divide by 365…

There’s no need to divide by anything and so no need to estimate the number of days per year:

- Subtract the year of the Date of Birth (DOB) (e.g. 2001) from the current year (e.g. 2021). This could be too high if we haven’t got to the birthday this year so…
- Subtract 1 if the current date
*with the year overwritten to the year of the DOB*is before the DOB (otherwise subtract 0).

This works perfectly for me, even with a birthday on 29 February.

In the value:formatted as number part, use 1 for yes and 0 for no.

I got to this simple solution thanks to the insight of @stei2348, thank you.

2 Likes

Thank you a lot!