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
In my humble opinion( It’s what we call a contraction, IMHO.)…
How about converting dates to numbers?
For example, March 31, 2025 can be converted to the number 20250331 , right? This may be confusing since it combines Format as and Convert to number operators.
In the Workflow I have put together, the year is truncated and converted to 0331, and then it determines if the birthday has been reached. Please see the screenshot below:
Second sequence set value mmdd of Custom format dialog.
P.S.
I’m relieved that I’m not the only one who is having trouble figuring out how to calculate birthdays in Bubble. It took me a total of 30 hours to come up with this method.