Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where do you reset

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
I am using the formula I found on this site to calculate the work days between 2 dates.

It works great if I choose one month but how do I reset it so that it counts the number of work days for each month individually?

i.e. Jan 2009 has 19
Feb 2009 has 19
so I want 19 to show for each month.
right now it shows 38 for both months.
Thanks
 
You need to show us your full formula. But it looks like you need to reset in Month header, assuming you have grouped by date.

Ian
 
Sorry here is what I have:

Group 1 header: Process Date
Group 2 header: Employee
columns of data are here

Page Header:
[blue]
@resetDays
whileprintingrecords;
numbervar workdays :=0;
[/blue]
Group 1 Footer:
Workday column is here
[blue]
@workdays
Code:
//Main formula
WhileReadingRecords;
Local DateVar Start := Date({?StartDate});   // place your Starting Date here
Local DateVar End := Date({?EndDate});  // place your Ending Date here
Local NumberVar Weeks; 
Local NumberVar Days; 
Local Numbervar Hol;
DateVar Array Holidays;

Weeks:= (Truncate (End - dayofWeek(End) + 1 
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 + 
(if DayOfWeek(Start) = 1 then -1 else 0)  + 
(if DayOfWeek(End) = 7 then -1 else 0);   

Local NumberVar i;
For i := 1 to Count (Holidays)
do (if DayOfWeek ( Holidays[i] ) in 2 to 6 and 
     Holidays[i] in start to end then Hol:=Hol+1 );

Weeks + Days - Hol
[/blue]

Thanks
 
I did that but was still having a problem with the days counted being correct so what I did was create a formula that had global values and put that in the group header.

Global DateVar Datein;
Global DateVar Dateout;


if month({Command.PROCESSDATE}) = 1 then
(
Datein := Date(Year({?StartDate}),01,01);
Dateout := Date(Year({?StartDate}),01,31)
)
else if month({Command.PROCESSDATE}) = 2 then
(
Datein := Date(Year({?StartDate}),02,01);
Dateout := Date(Year({?StartDate}),02,28)
)
etc.

Then in the original workdays formula, I used Datein and Dateout for the begin and end dates. This worked great. You guys don't get enough thanks so Thanks so much for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top