Report Design
 Crystal Reports Forum : Crystal Reports .NET 2003 : Report Design
Message Icon Topic: Number of specific days in specific month Post Reply Post New Topic
Author Message
avgmojoe
Newbie
Newbie


Joined: 23 May 2007
Location: United States
Online Status: Offline
Posts: 2
Quote avgmojoe Replybullet Topic: Number of specific days in specific month
    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
         
 


Edited by avgmojoe - 23 May 2007 at 10:26am
IP IP Logged
avgmojoe
Newbie
Newbie


Joined: 23 May 2007
Location: United States
Online Status: Offline
Posts: 2
Quote avgmojoe Replybullet Posted: 23 May 2007 at 11:56am
This is what I came up with:
//where @WeekDay is the numerical value of the day (Sun thru Sat = 1 thru 7)
 
 
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 , {@WeekDay} )
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.047 seconds.