Filter by age in RG using Date of Birth

Hi there. I have a data type for maids. And each maid will have a date of birth. I managed to figure out how to display the age in a RG by using this method: Calculate age by birthdays date - #6 by michael.fielding

However, I want to create a filter using the range slider element. The slider uses the age instead of DOB, for example user can select from 20 to 60 years old.

I am unable to figure out how to insert a constraint for the DOB field using age value to filter the age range.

Add a custom state that is a date and then when the slider input’s value is changed you can set the value of the state to be current date and time +years and then put -“this input’s value”. Then on your repating group add a conditional for if the custom state is not empty then search for maids :filter Advanced This maids DOB > custom state.

I managed to figure out how to set it up. I created 2 number custom states, min_age and max_age. On page load, I set min_age to slider min * -1 and max_age to slider max * -1. The reason is that in the RG constraint, I want to use [current date + year].

Because bubble.io doesn’t allow -year, I had to make the values negative.

It’s working now, however my pagination isn’t working well for the age filter and country filter. Was wondering if anyone can provide some insights.

This topic was automatically closed after 70 days. New replies are no longer allowed.