CR2016 : Set Static Date Parameters for Yesterday!

JustinBMak
JustinBMak used Ask the Experts™
on
Hello:

I am finishing building my custom Sales Order Report that I want to run with my ERP software automatically. The report will be scheduled every morning between 1a - 3a and needs to look at 'yesterday's' orders that was entered in and then e-mail it out to the correct folks.

I have literally spent over a week 'Googleing' around on the web different ways of explaining what I want like 'data parameters crystal report 2016', etc. and I have been A.) unable to find anything that is CR 2008, which has some what a different interface/options than the newer version (CR 2016 SP3) so I am having a hard time finding the information to at least point me in the right direction.

I know a Formula will need to be built then 'Parameter Field' I think but I am not achieving the result I am looking for.

Currently, I have a pop up box that appears and asks for a date, which is working if you manually enter in the dates. However as I previously mentioned I need the date to be set to 'yesterday's' date and not pop up a box so that my report can run automatically.

Thank you all!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Professor of MIS at Penn State Erie and Owner, Millet Software
Commented:
One option is to change the record selection formula to NOT use a parameter, instead use something like:
{YourTable.Your_Transaction_Date} = CurrentDate - 1

Another option is to use one of the 3rd-party Crystal Reports scheduling tools that can use relative date logic to feed the existing parameter the date value of yesterday.  At least some of the tools listed here provide such functionality.

Author

Commented:
Perfect! Didn't even think of the Record Selection Formula.

For folks that don't know what the 'Record Selection Formula' button is, in CR 2016 it's the yellow funnel in the center on the 3rd tool bar (default view).

In my @OrderDate formula, I changed it from:
(not HasValue({?Order Date (Optional Prompt)}) OR {@OrderDate} = {?Order Date (Optional Prompt)})

to

{@OrderDate} =  CurrentDate -1

Save and ran. Of course today is Monday so there were no orders entered yesterday. So I edited the query and put -3 instead (last Friday) and was able to retrieve the orders that were entered in on 04.05.19

Thank you again!
Top Expert 2011

Commented:
Removing the parameter and hard coding the value in the record selection formula will work if you need a report, which ALWAYS runs for yesterday. What will happen if Monday you want to run it for Friday prev week, or if Monday you are not in the office and you need to run it Tuesday or a week later? The best approach is to have a parameter for the date and to provide an external default value, which by default will be the yesterday date, but you can overwrite it if necessary. There are plenty of free tools, which can handle this scenario. R-Tag Community Edition is one of them (http://r-tag.com/Pages/CommunityEdition.aspx). You can check how relative dates work on page 3 of this document: http://r-tag.com/Content/Documents/R-TagFormulas.pdf 

This approach will allow you to use more sophisticated scenarios, for example, to set the default value to last used date +1 day.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial