formatDateTime($date, EEE) does not return 2nd day of each month in mendix

0
By using formatDateTime($date, 'EEE') = 'Sun' or parseInteger(formatDateTime($date, 'u')) = 7 in While loop, I got above observation for every month where 2nd day of each month is not calculating. As a result not getting exact calculation for calendar days of each by excluding sunday.
asked
4 answers
0

Hi Abhishek, 

Create a javaaction where you can pass the start and end date of the particular month and use the below code 

public static void main(String[] args) throws Exception {
    System.out.println(countDays("07/02/2018", "15/02/2018"));
}

public static int countDays(String startDate, String endDate) throws Exception {
    int workingDays = 0;

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

    Calendar startdate = Calendar.getInstance();
    startdate.setTime(sdf.parse(startDate));
    Calendar enddate = Calendar.getInstance();
    enddate.setTime(sdf.parse(endDate));

    while (!startdate.after(enddate)) {
        int day = startdate.get(Calendar.DAY_OF_WEEK);
        System.out.println(day);
        if (day != Calendar.SUNDAY) {
            workingDays++;
        }

        // increment start date, otherwise while will give infinite loop
        startdate.add(Calendar.DATE, 1);
    }

    return workingDays;
}
answered
1

Hi Abhishek, 

Can you explain your question a bit more clearly, what you are trying to achieve and what you have implemented it 

answered
1

I attach you my microflow solution

Screenshot 2024-05-10 155459.png

answered
0

image.png

 in second condition we checked "formatDateTime($date, 'EEE') = 'Sat' and parseInteger(formatDateTime(addDays($date,1),'dd'))= 2"

answered