Limited Time Offer: Watch All Our Bubble Tutorial Videos for Only $99 per Year! Date filter: Yesterday

Learn how to filter dates in by yesterday in this Bubble tutorial video.

I was recently helping a Bubble app builder in a Bubble coaching session filter by dates in that application and it can be a little bit tricky.

Filtering by Yesterday

In this Bubble tutorial video, I'm going to demonstrate how we can filter by yesterday. So I've got a calendar here. At the moment it is searching for all events and it's just going to return all events. And then I've got two printouts of dates here in order to show you what's exactly going on behind the scenes. But before I launch into that, if you're learning bubble, if you want to launch a no code SaaS, then there's no better place to do it than clicking the link down below and joining our community and accessing all of our videos through on our website.

Targeting Yesterday

So in order to target yesterday, we need to sandwich a date field between is it greater than this date and is it less than this date? So let's begin by getting the start of yesterday so I can say current date time, and then I could say days minus one and then rounded down today. Let's see how that prints out. So today's date is May 8. And there we go. We're going back to the start of yesterday.

Getting the End of Yesterday

Now, how do I get the end of yesterday? Well, I could, and this is going to be using the equal to or greater than and less than operators. So this would be perfect. I can just say rounded down to the day. Now, you might think strictly I'd need to then -1 second off it, but no, you don't. So this is going back to the very start of today, which is the moment after yesterday finishes, of course.

Applying the Constraints

In applying this to some constraints here, I can say date is equal to or greater than then I need the start of yesterday, which is current date time, days minus one, rounded down today. Okay, so that's midnight, the start of yesterday, but then the end of yesterday is just less than. So it's not equal to or less than, it's just less than midnight today. So current day time rounded down to today.

Creating Constraints for Yesterday's Events

Okay, so that's how you would create a constraint on some date fields to target events that only happened yesterday.

Latest videos