Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Counting weekdays in a period


Level 1

Hi experts,


I am not getting anywhere here.


The goal is to put out the number of individual weekdays days between two date fields.
In my form I could already generated a code, that put out the total number of working days in the entered period of datefield1 and datefield2.


How exactly can I realize that at the end is displayed for example:


Number of Mondays: 2
Number of Tuesdays: 2
Number of Wednesdays: 1


Here is my file:


4 Replies


Employee Advisor



try this


var startDate = new Date('15/03/2022');
var endDate = new Date('25/03/2022');
var numOfDates = getBusinessDatesCount(startDate,endDate);

function getBusinessDatesCount(startDate, endDate) {
    let count = 0;
    const curDate = new Date(startDate.getTime());
    while (curDate <= endDate) {
        const dayOfWeek = curDate.getDay();
        if(dayOfWeek !== 0 && dayOfWeek !== 6) count++;
        curDate.setDate(curDate.getDate() + 1);
    return count;


Level 1

Could you help me again and tell me where I should use that code in my following form?


The goal is to get a value of each working day in the entered period.


Here is my form:



Level 1



Here is the link to my form: https://www.acronaut.de/download/file.php?id=10008


It would be great, If you could help me with the code in my form.