Limited Time Offer: Watch All Our Bubble Tutorial Videos for Only $99 per Year! Date Filter: Last 30 days

Learn how to filter a list of dates to only return dates in the last 30 days in your app with this step-by-step tutorial.

Working with Dates in Bubble

Working with dates in bubble can be a little bit tricky. So here's my bubble tutorial video showing you how we can filter a list of dates to only return dates in the last 30 days. And if you're building a no code SaaS app with bubble, then click the link in the description, because we've got hundreds of videos just like this one to help accelerate your bubble app development journey.

Building an Expression for the Last 30 Days

Right, let's look at building an expression that targets the last 30 days. So I'm going to do it in this text field initially, because then you can see each step in action. So we can say current date time and we can say days, and it says plus days, but you can use a minus operator in here.

Understanding Relative Dates in Bubble

This isn't quite it, but I'm going to show you what this looks like, because it's currently May 8, 1130. Notice it is relative to time zone. And so now we go back to April 8, which would be 30 days ago, but it's saying 1130, which is going to miss any events that happened on April 8, 1030. And when a user is thinking last 30 days, they probably want all of April 8.

Rounding Down to Today's Date

So we go back in here and we can just say an ad to the end of it, rounded down today. Because now, if we look in the expression, we should have April 8, midnight right at the start of April 8. So we wanted to filter our calendar by that. Or it could be a repeating group, just anything with date data, like events.

Setting the Start Date in Bubble

We can say the start date that we want to have. The start of our date sandwich is going to be our expression of current date time. Days -30 rounded down to day. Okay. And then so that we don't accidentally get any events in the future.

Filtering Events in Bubble

For example, we could have the next 30 days, but we wouldn't want that included. Well, you've got to make a decision whether the last 30 days includes the day or not. But effectively, you could do something like this. Where is date is less than current date time.

Handling Future Events

Now, that's not perfect, because if we wanted our last 30 days expression to include events that are in the future, but are on today's date, we're going to miss them here. So instead we could say days plus one, rounded down to day.

Filtering Events by the Last 30 Days

So what that's going to do is take my current day, which is May 8. Oh, no. Days plus one. One rounded down. There we go. So that's going to take my current date, which is May 8 plus one, which would make May 9 at 1130, and then round it down. So that's going to be the midnight of May 9. And because we're using a less than and not a less than or equal to operator here, it's going to be the fraction before the start of May 9. So that's going to work. And that's how you can filter by the last 30 days in your bubble app.

Latest videos