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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excluding weekends

Status
Not open for further replies.

newbie0423

IS-IT--Management
Oct 29, 2012
103
US
Hi I have a report that shows the days that a surgeon performs cases. I would like to exclude his weekends cases. I have tried to use the below formula that I got from previous posts. However, it is only returning 1.00. Can someone please tell me what I'm missing.

WhileReadingRecords;
Local DateVar Start := {@startdate};
Local DateVar End := {@enddate};
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);


Thanks
V
 
The approach you are using is part of Ken Hamady's solution to count business days between 2 dates, found here: [Link] [/url].

If you are just looking to return only those records from weekday cases, you could simply exclude those records by adding the following code to your existing Record Selection formula:
Code:
and Not(DayOfWeek({Table.YourDateField}) in [1, 7])

Hope this helps.

Pete.
 
Thanks for responding Pete. I've tried this code and it only excludes the day from displaying not the entire record.
 
My aplologies Pete, this code works perfectly. Thanks again
 
What would the formula be if I wanted to return the result in date format vs. number of days?

And I was reading up on the Holidays part too...is ther a screenshot or a step by step way to do this? When you say put it in the Report Header what does that mean? I really new at this Crystal Report.
 
Hi amyceres

You should start a new thread with your question.

When doing so, please explain the problem as clearly as possible as I don't understand what you are asking. In regard to puting the formula in the Report Header, this refers to the section of the report where it is placed. The order that Crystal Reports processes formulas etc I determined by the section in which they are located.

Cheers

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top