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!

How can I set Date/Time Parameters to Today?

Status
Not open for further replies.

rsatty

Programmer
Nov 15, 2003
21
US
1.How can I set up a Date and Time Parameter to automatically set to yesterday's date and 12:00:00 AM?

2.Can I set up the report that when it is opened through a viewer or in design I automatically get a prompt to refresh the data?
 
My Parameter is called {?Date Range}

How do I write it and where do I write it?
 
1.Through the Crystal designer, there isn't a way to have a date parameter default to the pervious business day. You can set it up to default to a given day, but it will always default to that day regardless of when you are opening it.

There are ways to force the previous business day through logic in your Record Selection Criteria if you are looking to always run against the previous business day. I can supply more info if need be.

2.Unless the Save Data With Report option is set under the File menu, the report should always try to run against the database either in a report viewer or in the Report Designer when you hit the refresh button.

~Brian
 
If you can supply more info about the Record selection that would be great.

I guess there isn't a way to set up to automatically ask to run parameters from the beginning.

Thanks
 
One way to do it with one parameter is to create a default value that is out of your normal range of valid values.

I would set my default value to be 01/01/1900. That would be the only value in the drop down list for the parameter. A user could also change it to whatever valid date they choose.

Now, go to Report, Edit Selection Formula, Record.
In the editor, we can set up some logic to use the previous business day if the parameter date is 01/01/1900.
Code:
{table.date} =
switch
(
    {?date_parm} = CDate(1900,1,1),currentdate-1,
    {?date_parm} <> CDate(1900,1,1),{?date_parm}
)
This will return the proper selection criteria to the database in the WHERE clause of the SQL.

~Brian
 
One method in Crystal is to create a default value for a parameter:

Create a date parameter, select set default values and use 1/1/1970 (or what makes sense)

Select Report->Edit Selection Formula->Record

If minimum({?Date Range}) = cdate(1970,1,1) then
(
{table.date} >= cdate(year(currentdate),month(currentdate),day(currentdate),0,0,0)
and
{table.date} <= cdate(year(currentdate),month(currentdate),day(currentdate),23,59,59)
)
else If minimum({?Date Range}) <> cdate(1970,1,1) then
(
{table.date} = {?date range}
)

I responded to your other post, which didn't have as much information. Please refrain from cross-posting and try to supply technical information in your initial post.

-k

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top