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

Create a Specified Order Group using Dates

Status
Not open for further replies.

chaverly

Technical User
Sep 24, 2004
18
0
0
US
I am using Crystal Reports 8.5 and will be upgrading to 9.0 this week. My database is SQL Server.
I have a report that asks the user for a Parameter called Date. I would like to create a group on this {?Date} so it will be Month To Date and Year To Date. I tried a Specified group on the ondate field, but CR is not allowing me to select between Calculated Month start or Calculated Year start.

The trouble is it does not have to be the CurrentDate. For example the User selects 4/25/2005. The report wants all dates between 4/1/2005 and 4/25/2005 in one section all dates 1/1/2005 to 4/25/2005 in the next section. Can anyone help?
 
Assuming you would only be selecting records from 1/1/05 to 4/25/05 in the above example, you could group on month and put you month to date subtotals in the month group. Then suppress the group section if the month is not the month of the {?Date} prompt. Then add your subtotals in your report footer for the year to date totals.
MrBill
 
First you can't group on a parameter, and I'm assuming you really meant you were trying to group on a datefield. The issue is that one record cannot be in two groups. You could however, create two formulas like:

//{@monthtodate}:
if {table.date} in {?date}-day({?date}+1 to {?date} then {table.amt}

//{@yeartodate}:
if {table.date} in date(year({?date}),01,01) to {?date} then {table.amt}

You can then right click on each and insert grand totals.

-LB


 
I see what you both mean. I ended up having to do 2 subroutines and sending month start date and month end date to 1 subroutine and year start date and parameter date to the other subroutine.

Thanks, but I couldn't use suppress as I am doing a count and CR does count suppressed data.

What I was shocked about was why didn't my group select offer the formulas (such as month start date) as an option in the drop down list?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top