Quantcast
Channel: Microsoft Dynamics GP
Viewing all articles
Browse latest Browse all 59474

Forum Post: SSRS - Count of Business Days excluding Holidays

$
0
0

We have a SSRS report need to average the amount of GrossProfit over a range of business days; excluding holidays.

Currently the report is being run in Crystal Reports and copy/pasted into excel where a NETWORKDAYS formula is using a spreadsheet with the calendar days filled in.

The report must be fully automated with no need for human intervention and the result set will look like:

$5,000.00 GP/Day for the last 22 business days.

I found a code for a function that will calculate the weekdays minus the weekend days; but not one for also excluding holidays.  Before I go through the trouble of making a holiday/business day calendar table that will need to have the next 5-10 years and the prior 2-3 years; I wanted to see if anyone had tackled this problem before and what you did.

Here is the current code (I forgot the author):

Function getBusinessDaysCount(ByVal tFrom As Date, ByVal tTo As Date) As Integer

   Dim tCount As Integer

   Dim tProcessDate As Date = tFrom

   For x as Integer= 1 To DateDiff(DateInterval.Day, tFrom, tTo) + 1

     If Not (tProcessDate.DayOfWeek = DayOfWeek.Saturday Or tProcessDate.DayOfWeek =    DayOfWeek.Sunday) Then

       tCount = tCount + 1

     End If

     tProcessDate = DateAdd(DateInterval.Day, 1, tProcessDate)

   Next

   Return tCount

End Function


Viewing all articles
Browse latest Browse all 59474

Trending Articles



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