Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
mageshwaran_subramanian
Active Contributor
0 Kudos

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);
2 Comments
Labels in this area