Bubble.io Date filter: This Week
Learn how to filter data by the current week in Bubble.io for your no-code SaaS application.
Filter by current week: Discover the secrets to mastering date formatting in Bubble for precise weekly filtering.
Rounding down to Sunday or Monday: Learn how to manipulate dates and create flexible conditional statements for your Bubble app's calendar features.
Inelegant but effective: Explore advanced techniques for handling complex date scenarios in your no-code SaaS application.
Filtering by the Current Week in Bubble
In this Bubble tutorial video, I'm going to show you how you can filter by the current week on a list of dates. Now, I've been putting off doing weeks because to be honest, they're a little bit more tricky and have more to be considered than filtering by last 30 days or last month or even like the current year. So let me just begin by building an expression here. But before I do that, if you're learning Bubble, if you're building a no code SAS application, then click the link down in the description because we've got hundreds of Bubble tutorial videos just like this one and we've got a community of Bubble app builders ready for you to join.
Building the Expression for Current Week
So let's begin by building an expression here. So we need to get the start of this week. Now, first hurdle, what do we mean by that? Well, let's see what Bubble means by that by saying rounded down to week. So that's saying May 5th. Now, let me add a little bit more detail here so that it's clearer. We'll say formatted as... there we go. Because the big question here is, does it round down to Monday or does it round down to Sunday? So there we go. It rounds down to Sunday. So when we say round down to week, it is rounding us down to midnight on the Sunday.
Adjusting for Monday Start
Now, if you can work with that limitation in your Bubble app, then that's going to make things a lot easier. But of course we can add a little bit more further wiggle room here of... Whoops, didn't mean to delete that. Picking in here, taking this back. We could say rounded down to week plus one day. Let's see what that gets us. So there we go. Now... let's just add in the formatting. So that's really clear. So now we do get Monday.
Considering Edge Cases
Just be aware of how this could behave because what if you were on... Okay, so if you were on midday Sunday, you would round down and that would be the start of Sunday and then you could add one day. So then actually that's the Monday in the future even though the expression you've built here is intended to be the Monday in the past. So if you've got a better solution, leave a comment down below. I'd love to hear it.
Using Conditionals for Sunday
The way around that I found before is to effectively use a conditional and let me just give you a little point on that. So let's take this expression here and add it in as a constraint. So we'd say date is equal to or less than... If I just remove the formatting. Okay, so that's going to be rounded down to week plus one day, but it doesn't work if it's a Sunday.
Handling Sunday as a Special Case
So what you could do, and I think that this is fairly inelegant, is to say current date time. So basically you do a different thing if it's a Sunday. So we say current date time extract day. Now Sunday is a zero because it's an index value of the week day starting on Sunday. So Sunday is zero, Monday is one, all the way through to Saturday being six. So we're saying if it's a Sunday, we change the data source. That's what I mean. It's inelegant. And I'd love there to be a better solution.
Alternative Approach for Monday Start
If you wanted to start your week on a Monday. So this time, so if it's Sunday mid-day, we want to probably minus a day and then round it down. And then plus a day. I think so. So we say days minus one day. So that's going to take us into Saturday, which now means that if we round down to week, we are the previous Sunday. And then if we add a day, we get to the previous Monday. Like I say, it's inelegant. Let me know if there is a better solution to working with weeks. I'd love to hear it.
Get the Complete Bundle for Just $99
Access 3 courses, 390+ tutorials, and a vibrant community to support every step of your app-building journey.
Start building with total confidence
No more delays. With 30+ hours of expert content, you’ll have the insights needed to build effectively.
Find every solution in one place
No more searching across platforms for tutorials. Our bundle has everything you need, with 390+ videos covering every feature and technique.
Dive deep into every detail
Get beyond the basics with comprehensive, in-depth courses & no code tutorials that empower you to create a feature-rich, professional app.
Save over 70%!
Valued at $80
Valued at $85
Valued at $30
Valued at $110
Valued at $45
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Have questions?
We have answers!
Find answers to common questions about our membership plans, programs, and more.
We're here to help you launch your no code SaaS. Reach out to the team and we'll double check our vast library for useful content. We'll advise you on how we'd tackle the same problem and there's a good chance we'll record the video to help the wider community.
As a Planet No Code member, you'll receive a discount on our Bubble coaching sessions. Monthly members receive a 10% discount, while Annual members receive a 17.5% discount. To redeem your discount, simply log into your account and book a coaching session through our platform.
Our 8-week intensive mentorship program is designed to provide personalized guidance and support to help you accelerate your startup journey. You'll be matched with a startup expert who will work with you one-on-one to set goals, overcome challenges, and make rapid progress.
To apply for the Mastery Program, simply click the "Request Invitation" button on our pricing page and fill out the application form. Our team will review your application and schedule a call with you to discuss your goals and determine if the program is a good fit for your needs.
We accept all major credit cards, including Visa, Mastercard, American Express, and Discover.
While we don't offer a free trial, we do provide a 14-day money-back guarantee. If you're not completely satisfied with your membership within the first 14 days, simply contact our support team, and we'll issue a full refund.