Print Page | Close Window

Number of specific days in specific month

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=739
Printed Date: 18 May 2024 at 8:06pm


Topic: Number of specific days in specific month
Posted By: avgmojoe
Subject: Number of specific days in specific month
Date Posted: 23 May 2007 at 9:59am
I want to create a formula that returns the number of a specified day in a specific month.  Parameters would be a Date Value (to get month and year) and the day of the week you are looking for.
 
Example, if I wanted to know the number of Fridays in March of 2007 it would return 5.
 
 
(side note:
I am using this to calculate average x done per hour by day.
This was after realizing that if I used total x per hour for all (fridays) / distict count of dates, I was getting a scewed average because I wasn't counting those dates with zero x's done.  I hope I am going about this in a more efficient manner and not missing something easier)
 
Month
   Weekday
       Hour
          Date
 
April
   Monday
       8 am
         4/23/07
              X1
              X2
                  So the avg X done at 8 am should be 2 / 5 (# of Mon in Apr)
       9 am
         4/2/07
              X1
              X2
         4/16/07
              X3
          4/30/07
              X4
              X5
                  So the avg X done at 9 am should be 5 / 5
         
 



Replies:
Posted By: avgmojoe
Date Posted: 23 May 2007 at 11:56am
This is what I came up with:
 
 
local datevar StartDate;
local datevar EndDate;
StartDate := DateSerial(Year({DTTM}), Month({DTTM}),1);
EndDate := Date(DateAdd("m",1,DateSerial(Year({DTTM}), Month({DTTM}),1)) - 1);
DateDiff ( 'ww' , StartDate - 1 , EndDate , mailto:%7b@WeekDay - {@WeekDay } )



Print Page | Close Window