Working with Dates in Bubble
Let's be honest, working with dates in Bubble could probably be a bit easier. But in this Bubble tutorial video, I'm going to show you how you can filter by this month on a list of dates. So I'm going to start by adding it into this text label because then you can see what's going on behind the scenes. And then ultimately I'll be applying it as a constraint to this calendar, but you could equally do the same thing to a repeating group.
Learning Bubble
But for an auction stat if you're learning Bubble, there's no better way than clicking the link down in the description heading over to our website. Joining our community of Bubble builders and learning from our hundreds of Bubble tutorial videos.
Filtering by This Month
So what we're doing, we are doing this month so we can say current date time rounded down to month and let's see how that prints. So today is May 8th and then of course we get back May 1st midnight rounded down to the start of this month. Now just remember that this is relative to the user's time zone and the user's time zone is provided by their browser.
Time Zone Considerations
So you wouldn't get the same simultaneous instance in time if two different users rounded down the day or the month that they were in different time zones because it's going to be relative to them.
Applying Constraints
We then need to basically sandwich it because that's all you need to do if you know that there's going to be nothing in the future because you just need to have one slice of the sandwich, which is don't go earlier than the start of this month. So let's place this into our constraints on our events data type here.
Setting Up Date Constraints
So we say date is equal to and this is just a date field you could have start date and date whatever you need to use. Say current date time rounded down to month. Okay, but then what about if we did have events in our system that were later than this month so we say date. Now we just say less than that's because we're going to actually target midnight of the first day of the next month so we can say month add one and then now we round it down to month.
Finalizing the Filter
So that's what's today I say May 8th. So that's going to take us into the June 8th and then round it down to midnight June 1st. And because I'm using the less than and not less than or equal to is actually going to be the moment before we move into June 1st, which is perfect for here. So there you go. That's how we can do this month filtering dates in Bubble.