Introduction to Date Filtering in Bubble.io
In this Bubble tutorial video, I'm going to show you how we can filter a list of dates to only show entries in our database where a date field is last month. But before I do that, if you're building a Bubble app, you're building a no-code SAS application, click the link down in the description because we've got hundreds of Bubble tutorial videos just like this one.
Understanding the Concept of Last Month
So yeah, last month. I'm going to begin by building an expression in a text field here because that's going to just show you what's going on behind the scenes. We need to sandwich a date field between a start date and an end date.
Creating the Start Date for Last Month
So the start date of last month we would arrive there by going something like current date to time month, add months, minus one month. So today's May 8th, that's going to take us to April 8th. Then we need to round it down to month. Notice that this is all time zone relevant, relative, time zone relative.
Previewing the Result
Let's preview that. So we should hopefully see April 1st. There we go, midnight April 1st.
Implementing the Date Filter in Bubble.io
So on our events or our calendar, we can say date is greater than and let's get our April 1st expression in there, current date time, month plus months minus one, round it down to month.
Adding the End Date for Last Month
Okay, but now what if we've got events in May, my current month? So we would say date, come back, is less than and now we need the start of the current month. Well I think you can guess how we get there. So we say current date time, round it down to month.
Conclusion
Okay, there you go, that's how you can target last month in Bubble with date filters and date constraints.