Here's the code that can be used within a custom function to find the number of days between two dates excluding weekends.
It uses Data Services's built-in-function day_in_week().
$l_Start and $l_End are the two input dates ; $l_last_weekday_7 and $l_last_weekday_6 are of type DATE ; $l_workdays is INT
$l_last_weekday_7 = $l_start + ((7 - day_in_week($l_start))%7);
$l_last_weekday_6 = $l_end + ((-1 * (day_in_week($l_end) + 1))%7);
$l_workdays= ((($l_last_weekday_6 - $l_last_weekday_7) + 1) / 7) * 5;
$l_workdays= decode ( ($l_last_weekday_7 <> $l_start) , $l_workdays+ (6 - day_in_week($l_start)),0);
$l_workdays = decode ( ($l_last_weekday_6 <> $l_end ) and (day_in_week($l_end) <6) , $l_workdays+ day_in_week($l_end) , $l_workdays);
print ($l_workdays);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |