Tuesday, March 22, 2011

Crystal Reports : Changing the CURRENTDATE

It is very often that you may have a report that uses "Today" as one of it's parameters.
This is nice if you are looking back seven days from "Today", etc. Reducing parameter choices for your end-users always makes it a little easier to print the report.

Let us suppose we have the following code in our Selection Expert:

{CONTHIST.ONDATE} >= (CURRENTDATE - 7)

So, what this is saying is give me all histories within the last 7 days.

However, if you ever need to "trick" this report to generate MORE than the last seven days, you can certainly modify the selection criteria. But there is a trickier way to make this happen:

Go to Report | Set Print Date and Time. Here you can tell Crystal what date and time it should think it is. What it actually does is change the date returned by the CURRENTDATE function.

Try it!

No comments: