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

Passing a variable to Date Select in Report 1

Status
Not open for further replies.

rekree8

Technical User
Jun 10, 2003
6
US
Hello - Another beginner question:

My report needs to segregate information into five groups - Todays Date, Month to Date, Year to Date, Month to date Prior Year, and Total to date same day prior year. There are functions that I am using in formulas to display each of these in columns. My problem iswith Today's Date - I am using the function CurrentDate and it is picking up the computers system date. I would rather pass a date to it so that my users can select "Today's Date" of their choice. If I use the Select Expert, I limit the records populating the report. What could I do to have a selection capability for my users, have that pass to a variable that controls Today's Date, and not limit the record selection of the report?

Thanks in advance.
 
Are you intending to limit the Monthtodate, etc. based on this todays date?

Is the date being compared to a date or a datetime?

I'll assume a datetime

Create a parameter to enter in a date, and then build out a start and end date formulas based on the input:

@start
{?dateparm}-1

@end
{?dateparm}+1

Now any formula or Running Total filtering the date entered could use these formulas as in:

{table.date} > @start
and
{table.date} < @end

-k
 
thanks synaps for your replies in the forum.
maybe it's simpler to write
{table.date}={?dateparm} for filtering?
 
tekti: That depends on the field, I thought that the requirement here is for the day before the parm, and if you have a datetime field, you may encounter problems with what Crystal generates as the SQL, if anything.

The key is to check the Database->Show SQL Query

-k
 
Thanks Synapse and Tekti - part of this sunk in, but I can now give you more info as the requirement has been further refined.

I am using a parameter field as a daily date in a main report. What I would like to do is pass this parameter into selection formulas in subreports that are then using this date to define a &quot;To Date&quot; component in a &quot;Year to Date&quot; selection.

So, for example, if today is June 30, 2003 and my main report is using this date to pull the pertinent data into it, my subreports will use today's date as reference to create a range selection that uses the same month but from the prior year as the Year to Date. In that subreport, I would like to create a range that starts at Jan. 1 of that year and extends to the date that is today's date one year ago. So I guess I would need a way to calculate not only todays date as of last year, but also a range that goes back to the beginning of that year.

I hope this is clear. I was using the YearToDate and LastYearToDate functions, and they were great. But they respond to the system date - not to parameters.

Thanks in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top