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

Date range selection 1

Status
Not open for further replies.

trivalent

Technical User
Feb 21, 2007
28
US
I have written a report that asks the end-user to select a program name from a list of treatment programs names. The report returns all the people currently in the selected program and the date they were admitted. What I would like to accomplish is to have the end-user to enter a date rang in addition the program name and print out the number of people that were in the program per day in the date range. Example I select the program end a date range of 3/1/07 to 3/8/07 and then print out 3/1/07 had 5 people, 3/2/07 had 7 people ect. I need a path to follow to accoplish if it is possible in CR Thanks.
 
Code:
?Prog_Param = {data.prog} and
{data.end_date in [?startdate to ?enddate]

It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
what madawc said is right, you want some code like that in your record selection. are you planning on displaying each day in that date range and showing how many people were in that program on each day?
if so i guess you will need to group on the date field and add a running total field to count how many people are in each group
 
I am using CR 11. Bloke152 you are correct. I wnat to display each day in that date range and show the number of people who were in that program on each day.

This is my record selection formula

{view_episode_summary_current.program_value}= {?Program} and
{admission_data.admission_date} >= {?Start Date} and
{admission_data.admission_date} <= {?End Date} and
{view_episode_summary_current.FACILITY}=1

This gets me all the people that were admitted in a date range. I for the live of me cant figure out how in CR to display the count of people in a date range. Any ideas?
 
I guess the question is whether people participate over a period of days or whether the admission date is the only date you need to capture per person in the date range.

-LB
 
People are in the program for a period of days and possible weeks. So if somebody was admitted on 1/1 and discharger on 1/20 and another person was admitted on 1/5 and discharged on 1/25. I want to enter a selection date range between 1/15 to 1/24 and have CR print the date and the number of people in the program on each day in the give date range. I just dont know were to begin.
 
So do you have a discharge date field?

-LB
 
To get the counts for particular dates, you would have to create a formula for each date in the period. First you should change your record selection formula to something like:

{view_episode_summary_current.program_value}= {?Program} and
{admission_data.discharge_date} >= {?Start Date} and
{admission_data.admission_date} <= {?End Date} and
{view_episode_summary_current.FACILITY}=1

You will need to decide what the maximum number of days in the range will be and then create one formula per day, as in:

//{@day1}:
local numbervar i := 0;
local numbervar j := datediff("d",{?Start Date},{?End Date})+1;
local datevar array x;
redim preserve x[j];

for i := 1 to j do(
x := {?Start}-1+i
);
if x[1] >= {admission_data.admission_date} and
x[1] <= {admission_data.discharge_date} then 1

//{@day2}:
local numbervar i := 0;
local numbervar j := datediff("d",{?Start Date},{?End Date})+1;
local datevar array x;
redim preserve x[j];

for i := 1 to j do(
x := {?Start}-1+i
);
if x[2] >= {admission_data.admission_date} and
x[2] <= {admission_data.discharge_date} then 1

Notice that the only change in the formula is the subscript in the last clause of each formula. Repeat for all possible number of days. Then place these in your detail section and right click on each and insert sums at the group or report level.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top