If negative number in a text box, then show 0 or some message


I cant seem to figure out how to do a very basic if/then when a number falls below 0. In the below image, I would like the Due in (Days) not to go below 0, if it does, then show some message like “Overdue” or even just the number 0.

Ive tried figuring it out in the conditional with no luck.

Is there a way to do this?

Thanks in advance!

Figured it out… however, now the text says “Overdue” even if the number is above -1.

Is “Due Date” not a date?

Don’t confuse date formatting (rendering a date in a human readable format with, e.g., :formatted as…) with date operations.

If we have date object “DueDate”, we can format it as you are probably doing:

DueDate :formatted as (settings)

:point_up: This is no longer a date. It is a text (a string).

So, to present DueDate differently, we operate on it “in date land” first, before converting anything to text.

Now, an expression that resolves to true (“yes” in Bubble parlance) if the date is “overdue” is this:

DueDate < Current Date/Time

:point_up: This is no longer a date, it is a boolean (“yes/no”).

And now we can format that however we want:

DueDate < Current Date/Time :formatted as…

And you will see a dialog that allows you to construct a text for “yes” and a text for “no”. Build whatever you like there.

And now that expression is a text.

If we wanted to go on to style it, we could use a Condition on its parent object, but you should get the idea at this point!

Keith, thanks for the quick reply. The “Due Date” is a date and the “Due In” text box is the Due Date minus the created date, formated as days.

I have tried multiple combinations in the conditional tab but still have not been able to figure it out. Would I use “current cells index” or “this text”?

Also, once this issue is figured out, I would like to use this text as a number to create an analytics report based of # of days, etc. Is this not possible?


This topic was automatically closed after 70 days. New replies are no longer allowed.