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

Combing Days of Week

Status
Not open for further replies.

vblack7770

Programmer
Apr 11, 2005
26
US
I am using Crystal 8.5 with a Oracle ODBC connection - Oracle v9. I am working on a report that will be pulled daily and give the count of total records in a group by day.
I am using the DayOfWeek({table.date}) formula to get the 1 thru 7. How do I go one step further to obtain the records I need grouped as follows for Sun & Monday:
Sun - Total Fri and Sat records together
Mon - Total Fri, Sat & Sun records together

My report is grouped as follows: group 1 = team, group 2 =team
Totals for each group are in stages: Stage 1, Stage 2, etc.
I want to total all records in Stage 1 for currentdate - 1 if the weekday(currentdate) is in [3-7] but total it differently (see above) if weekday(currentdate) in [1,2].
 
Sorry, title should be Combining Days of Week records.
 
This will require manual sums as GROUPING does not double count rows.

So you'll want seperate formulas, as in:

Sun:
whileprintingrecords;
numbervar Sun;
if dayofweek({table.date}) in [5,6] then
Sun := Sun +{table.amount}

Mon:
whileprintingrecords;
numbervar Mon;
if dayofweek({table.date}) in [5,6,1] then
Mon := Mon + {table.amount}

Now display totals in the report footer using their respective formulas totals formula, as in:

Sun:
whileprintingrecords;
numbervar Sun

It appears that the rest of the days are simply their own previous day amounts.

Now the record selection formula should be:

{table.date} >= {table.date} - 7
and
{table.date} <= {table.date} - 1

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top