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!

Problem with parameters

Status
Not open for further replies.

musini

Technical User
Jan 19, 2008
75
US
Hi,

I have a report with two parameters startdate and enddate. These parameters I have attached to the query in the command. Now it is fine that when ever there is a value given for the parameters, the report run fine but what I want is if there is no parameter specified, the report should run for the 1st day and last day of the previous month IRRESPECTIVE OF ON WHAT DAY IT IS RUN IN THE PRESENT MONTH.

Thanks,
M
 
You could use

Code:
{table.datefield} in LastFullMonth

-lw
 
Hi,

Thanks for the fast response but I am confused. It meance I should not use the parameter at all and where do I write the formula you mentionoed. I have never worked on someting like this before, It would be great if I can get more details on this.

Thanks,
M
 
If you are using Crystal XI with an Oracle DB, then the following can be used in the command

Code:
select to_date(to_char(add_months(sysdate,-1),'MM')
  ||'01'
  ||to_char(add_months(sysdate,-1),'YYYY'),
  'MMDDYYYY') "StartDate",
  sysdate-(to_number(to_char(sysdate,'dd'))) "EndDate"
from dual;

I just used from dual to verify the code.

-lw
 
KsKid Thanks for the response.

Yes I am using the oracle DB and crystal XI and I know we could directly hardcode it but I also want the parameter to the report, so that if the user wants to run it it will ask for the parameters and if he does not enter any thing the repot should picke the lastmonth first and last days automatically. If I hardcode it we are opting out the option of giving dates what the user wants. My questions is can crystal handle this situation?

To summarize I need the flexibility of running with what ever the date are given by the user and if the dates are not provided it should automatically pick the lastmonth's first and last days. Why I am asking this is because this situation can be handled in oracle reports and I want to make sure if crystal can do it or not.

Thanks,
M
 
Yes. You can.

1. Set default values for your start and end dates. I use 1900-01-01 and 1900-01-31 since Crystal won't let you get pass this screen without input.

2. In your record selection formula, add the following.

(
if {?-StartDate} = date(1900,1,1) and
{?-EndDate} in date(1900-1-31)
then
table.datefield in LastFullMonth
else
table.datefield in [{?-StartDate} to {?-EndDate}]
)


-lw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top