Calculate between dates and return a list

Hello,

I am a teacher and am in the process of developing a tool that will allow me to create a yearly schedule. For this I have a database called vacations and have put in here all the region bound vacations. These regions are North,Central and South. When I choose a region in the Full Calander plugin it changes automatically. However, now users also have the option, if they are logged in to also add additional days off or study days in the same database. This works so far. However, I would now like a list with only the school days, i.e. without the vacations and the vacations added by the users. Can anyone get me started on how to get this done?

Translated with DeepL.com (free version)

You can use filter or constraints

To make it easier, add another field called is_vacation with yes/no data type. Therefore, you can easily filter if it’s a vacation or not using the is_vacation identifier.

1 Like

Thank you and thanks for thinking with me-)

Is there a easy way to calculate the days between a given start and endtime? I’ve placed two datepickers called start startdate and enddate. In the workflow both have a custom state to hold the given date. This is step 1 for both elements on the workflow. When enddate’s value is changed and when startdate’s value is changed before that off cource. Now i’m using the toolbox to run a javascript:let startDatum = new Date(arguments[0]); // De eerste parameter als startdatum
let eindDatum = new Date(arguments[1]); // De tweede parameter als einddatum
console.log(“Startdatum:”, startDatum); // Dit logt de startdatum naar de console
console.log(“Einddatum:”, eindDatum); // Dit logt de einddatum naar de console
let tussenDatums = ;

for(let dt = new Date(startDatum); dt <= eindDatum; dt.setDate(dt.getDate() + 1)) {
tussenDatums.push(new Date(dt).toISOString().slice(0, 10));
}

bubble_fn_mijnData(tussenDatums); // Verzend de lijst van datums terug naar Bubble

In the front i’m using the js2 buble pluging to show a list of dates . The settings i use are bubble_fn_suffix: mijnData trigger event and publish event are set to true. The value type is text. What am i doing wrong here?

I’m using two datapickers called StartDatePicker (param1) and EndDatePicker (param 2) and JS2BUBBLE to calculate and return a list of dates between these two parameters.

The ID of the JS2BUBBLE is js_to_bubble_dates . bubble_fn_suffix : dates trigger event and publish value are checked and the value type is text.

The repeating group contains text elements that refer to : js_to_bubble_date’s value. I’m using the following javascript:

function generateDates() {
var start = new Date(properties.param1);
var end = new Date(properties.param2);
var dateArray = ;

console.log('Startdatum:', start);
console.log('Einddatum:', end);

while (start <= end) {
    dateArray.push(new Date(start).toISOString().split('T')[0]);
    start.setDate(start.getDate() + 1);
}

console.log('Gegenereerde datums:', dateArray);

if (typeof bubble_fn_dates !== 'undefined') {
    bubble_fn_dates(dateArray);
    console.log('Data is verzonden naar Bubble');
} else {
    console.error('bubble_fn_dates is not defined. Please check your JavaScript to Bubble element\'s configuration.');
}

}

generateDates();

Unfortunaly it doesn’t work-( What am i doing wrong here?

Sorry I don’t understand what you’re trying to do, do you want to get the duration between start date and end date? If that’s the case, then you can just subtract end date to start date then extract the days.

End Date’s value - Start Date’s value:extract days