RE: Want to calculate days in a week except Saturday and Sunday in between selected dates.
If you don't use work calendar, you can simply iterate through all the dates and use the dayOfWk(date) function to extract the day of week.
Or, for better performance, check the dayOfWk of the start date and dayOfWk of the end date and figure out how many full weeks there must be in between. I'm not going to write the code for you but it should be quite easy.
Also DateTimeUtil::getDifference can be used to get the difference of two dates.
The logic would be something like this:
- How many weekdays (Mon-Fri) are there from the start date until end of that week?
- How many weekdays (Mon-Fri) are there from the end date until the beginning of that week?
- How many full weeks are in between the two dates? Nr of weeks * 5 is the nr of working days.
Then combine the results of those three calculations.
So, depending on the requirement I would use "dummy iteration" (if the difference between the start and end date is always small) or write a more clever algorithm (if the code needs to handle difference of many years).