First off, I didn’t mean to disparage your response, and apologize if that’s how you interpreted it. My intention was to acknowledge that your response actually does work in edge cases, and to provide an alternative for those who don’t want to rely on external sources which we don’t have control over.
In regards to the code not working, I was able to test it out just now in an internal app, and it seems to work fine on my end. I’d love to share a link to an editor to demonstrate this, but unfortunately backend workflows require a paid plan.
If you let me know what issue you’re having, I’d be happy to help you debug it. Your use case of months should be possible with slight modifications.
I’m also working on a plugin which will have a number of useful datetime-related utilities including get age, so I can update this thread when I’ve finished it.
“Current time:extract date >= BIRTHDAY:extract date:formatted as text”
if yes → Current time:extract year - BIRTHDAY:extract year
if not → Current time:extract year - BIRTHDAY:extract year - 1
I also had to determine somebody’s age depending on a field called “Date de naissance” (date of birth in french) that I wanted to compare to the current date and then store the result in an another field called “Age”.
Here is how I did it, i works fine, at least fo me
On the “Age” field, Appearence - Content format = Integer
On the “Age” field, Appearence - Initial content :
On the “Age” field, Conditional, added those 3 conditions :
And that’s all.
To explain how it works, as there is no predefined method in Bubble to handle this “out of the box”, I implemented the following logic :
You can use current date extract year - date pickers value extract year, then condition show only visible when current date extract date < date pickers value extract date , then text value would be current date extract year - date pickers value extract year -1