Quantcast
Channel: SCN : All Content - Data Services and Data Quality
Viewing all articles
Browse latest Browse all 4013

Custom function : Number of days between two dates excluding weekends

$
0
0

Here's the 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_Diff =  day_in_week($L_End) - day_in_week($L_Start) ; 

$L_Output = ((date_diff(  $L_End,$L_Start,'D')- $L_Diff) / 7 * 5)  + (decode(($L_Diff <5) ,$L_Diff,5))-

decode ( day_in_week($L_End)-4> 0 , day_in_week($L_End)-4 ,0)%5

return($L_Output);

 


Viewing all articles
Browse latest Browse all 4013

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>