tensixtyone

Rants of Andrew Williams / Nik_Doof

First Working Day in Crystal Reports

with 2 comments

From time to time, to save on resources and make things easier you have to bodge certain items. Today’s example is generating a different report on the first working day of the month than the rest of the month. Crystal Reports doesn’t offer the functionality to identify the first working day of the month, so i’ve created the following fuction:

Function FirstWorkingDayOfMonth(d as Date)
   dim td as date

   ' Grab the first day of the month and check what day of the week it is
   td = datevalue(Year(d),Month(d),1)

   select case dayofweek(td,crMonday)
      case 6
         ' Saturday
         FirstWorkingDayOfMonth = datevalue(year(d),month(d),3)
      case 7
         ' Sunday
         FirstWorkingDayOfMonth = datevalue(year(d),month(d),2)
      case else
         FirstWorkingDayOfMonth = td
   end select
End Function

Just incase this is handy for anyone else.

Written by Andrew Williams

March 13th, 2008 at 1:13 pm

2 Responses to 'First Working Day in Crystal Reports'

Subscribe to comments with RSS or TrackBack to 'First Working Day in Crystal Reports'.

  1. How I have to apply this to my report..Crystal doesn’t gives us option to write the function

    Neeraj

    30 Jun 09 at 12:35 pm

  2. @Neeraj

    Add it as a Report Custom Function.

    Andrew Williams

    30 Jun 09 at 4:55 pm

Leave a Reply