Would you please help us to implement loops(like 'for', 'while' loop etc...)
For example, i want to find out number of working days between '12-Sep-2009' and '23-Nov-2009'. It suppose to exclude all Saturdays and Sundays.
To register for the forums, please contact your Digital-Clay representative.
Loops
-
ZevToledano
- Posts: 722
- Joined: Fri Apr 03, 2009 2:29 pm
Re: Loops
General automation loops (for running actions inside a loop) are planned for 8.8.0 in a couple of months or so, but I don't think this is what you are looking for here.
The best I can come up with to calculate workdays using a function is something like this:
1 + daydiff(<date1>,<date2>) -
2 - (weekdiff(<date1>,<date2>) * 2) +
if(weekday(<date1>)>1,1,0) +
if(weekday(<date2>)<7,1,0)
Line by line explanation:
1. Calculate amount of total days including current day
2. Subtract two days per week, including 2 days for the starting week
3. Add one day if starting week doesnt include a Sunday
4. Add one day if ending week doesnt include a Saturday - this includes the case where start week is the same as end week
Of course this is for inclusive dates, otherwise you'll have to modify this accordingly
The best I can come up with to calculate workdays using a function is something like this:
1 + daydiff(<date1>,<date2>) -
2 - (weekdiff(<date1>,<date2>) * 2) +
if(weekday(<date1>)>1,1,0) +
if(weekday(<date2>)<7,1,0)
Line by line explanation:
1. Calculate amount of total days including current day
2. Subtract two days per week, including 2 days for the starting week
3. Add one day if starting week doesnt include a Sunday
4. Add one day if ending week doesnt include a Saturday - this includes the case where start week is the same as end week
Of course this is for inclusive dates, otherwise you'll have to modify this accordingly