Counting only weekdays in your Bubble.io no code app requires understanding how Bubble handles day extraction and implementing proper filtering constraints to exclude weekends from your calculations.
Understanding Bubble's Day Extraction System
Bubble.io uses an index-based system for days of the week when you extract the day from a date. Sunday returns 0, Monday returns 1, Tuesday returns 2, and so on through Saturday which returns 6. This numerical system is the foundation for filtering out weekends in your no code app.
To extract the day from any date field in Bubble, you use the extract day function on your date field. This will return a number between 0 and 6 representing the day of the week.
Filtering Weekdays Using Constraints
To count only weekdays, you need to exclude both Saturday and Sunday from your date calculations. Since Sunday equals 0 and Saturday equals 6, you can filter your date list using these constraints:
Day is not 0 (excludes Sunday)
Day is not 6 (excludes Saturday)
When working with a date range or list of dates, you can filter the list and apply these constraints to the extracted day value. This ensures only Monday through Friday dates remain in your filtered results.
Counting Weekdays in Date Ranges
For counting weekdays within a specific date range, you can use a date picker or define your own date range parameters. Start with your date range as a list, then filter that list using the weekday constraints mentioned above.
After filtering your date list to exclude weekends, you can use Bubble's count function to get the total number of weekdays. This gives you a numerical result that represents only the business days within your specified range.
If you need to display the weekday dates, you can format the filtered list using the join with function and include line breaks between entries for better readability.
Database Query Applications
When querying your database for records created on weekdays only, you can apply the same filtering logic to your search constraints. Add constraints to your database search where the creation date's extracted day is not 0 and not 6.
This approach works particularly well for business applications that need to analyze activity during working hours, calculate business day intervals, or generate reports that exclude weekend data.
Workflow Implementation for Weekday Calculations
In your Bubble.io workflows, you can implement weekday counting for various scenarios such as calculating project timelines, determining service delivery dates, or scheduling automated tasks for business days only.
Create custom states or database fields to store your weekday counts, and use the filtering technique within your workflow actions to ensure accurate business day calculations throughout your no code application.
Remember that this method works with any date field in your Bubble app, whether it's user-generated dates, system timestamps, or imported date data from external sources.