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

Grouping on variable intervals #2 1

Status
Not open for further replies.

suecobb

Programmer
Sep 18, 2001
32
0
0
US
I found a post on grouping on variable intervals, but it's not quite what I'm looking for. I am using Crystal 10 and the report runs against a .ttx file passed in from an application. I have data with a date field and I need to group on the date field based on the interval the user chooses at run time. I'm guessing this will be passed to me as a parameter, but I don't have that information from the programmer yet. The choices presented to the user are day, week, month, quarter, or year, so it's more complicated that just the number of days in each interval. It will have to take into consideration what day each interval starts. Any ideas? Is there an easy way to do this?
 
Set up a parameter {?Interval} with options like "Annually", "Quarterly", etc., and then create a formula to insert a group on:

select {?Interval}
case "Annually" : date(year({table.date}),1,1)
case "Quarterly" : date(year({table.date}), (datepart("q",{table.date})*3)-2,1
case "Monthly" : {table.date}-day({table.date}) + 1
case "Weekly" : {table.date}-dayofweek({table.date})+1
case "Daily" : {table.date}

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top