Forum Academy Marketplace Showcase Pricing Features

Birthday days away algorithm help [Resolved]

Hey guys, I’ve been trying to figure this out for over an hour and i just can’t crack it.

I have User’s birthdays in their thing model. I’d like to simply show how many days away someones birthday is, Formatted as "Birthday: April 25, 12 days away)

Right now, i am doing:
“Current date/time - Contacts Birthday:format as days:rounded to 0 - 365 *-1”

But with this forumla, i am getting numbers like “380 days away”, and i’m not sure how to fix it. I want the number to be between 1-364, of course.


1 Like

Try this:


hmm, for dates in the past i’m still getting -X days

Is the number correct though? If it is, you may need to switch which date is subtracted from which.

The formula I used subtracts the current date from the D.O.B., and I changed the D.O.B. year to the current year so that the D.O.B. date is greater than current date since you’re doing a countdown to a future date.

okay, lets think this through.

2 birthdays
X = January 10
Y = January 30

and Todays Date is:
G = January 20

so if we subtract Current date from birthday we get
X = 10
Y = - 10

And if we subtract Birthday from Current date we get
X = -10
Y = 10

that math checks out, right?
so it looks like regardless of order, we get a negative number. I need a way to tell Bubble to always subtract from 365 or something.

Oh I see what’s happening. I assumed you had years figured into these. Are your formulas including the years? Doing math with dates can work the way you’re after if your data is type date and you’re not leaving out the years in the calculation. That’s why I changed DOB to current year so that those 2 dates are recognized as dates, counting within one year, to get a positive number


I’m not sure i’m following what you are trying to say.
I tried your forumla, and while the numbers were correct, i was getting negative numbers.

right now, if i could add a “if negative number, add 365” to the forumla you gave, i think it would work perfectly.

Do you have a link?

id prefer not sure to share it, as bad as that may sound lol.

Not a problem. Could you reproduce in the forum app?

Ok! For the one you built, I altered it so that users can select their actual birthdate with their birth year, but then I realized why you were doing it the way you were in the first place - selecting the year is cumbersome.

So then I created the one below it. Check it out. There are conditions in the text elements to cover all bases: when the birthday has passed, when the birthday is coming up, and when the number returned is less than zero (switches the order of operation… that may now be redundant with my other conditions…) but anyway, let me know if this is it.

oh nice! thanks so much! is there a way to have it always be “in X days” (rather than every being x days ago?)

Oh, you mean, if the birthday is passed and it’s now counting to next year?

EDIT: If that’s what you mean, I just changed that condition to add 365. Check it out.

yup, but i’m looking at it and there is 396 days and 437 days :frowning:

i think it needs to be “if negative number add 365”

Right, because those dates are in the past, so it’s counting to those days in 2017, over a year away.

that can’t be it…every day occurs once every 365 days. The highest the number should ever be is 364, and thats when the bday was yesterday.

For example in the forum app, Johns Bday is Feb 1st, and it says the bday is in 438 days. But really, Feb 1st is in 294 days from today.

Oh I see, I confused myself there. Let me look at that again… be right back

1 Like

Fixed! Just had to switch the order of subtraction, THEN add 365.


! looks awesome. Thanks so much! this thread is a true testmanet to bubblers helping each other out.
I will add that i never realized you can change text as a conditional. I can probably clean up ~20 workflows in my projects from just that single tip.
Again, thank you!