Using Crystal’s pre-programmed date ranges

Wednesday 9 November 2016 @ 10:57 am

One of my customers learned a new trick from me today. They wanted a report to automatically select the data for the prior month. They didn’t realized that Crystal has a dedicated function for that and you can use it in both the select expert or in the selection formula. So I figured I would share this, since there may be others that have never seen this function in Crystal.

Go into your select expert and add a rule using any field that is a Date or DateTime. Then in the comparison list look toward the bottom for the option “is in the period”. When you select this option the next drop-down list will automatically populate with 25 pre-programmed functions. You will find items like “LastFullWeek”, “LastFullMonth” and “YearToDate”. These periods are automatically calculated each time you run the report, based on today’s date.
So say you want a report to automatically select the records for the prior month without having to enter the date range or change the report each time. You use the LastFullMonth option in the select expert, or you could do the equivalent, like this, in the selection formula:

{Date.Field} in LastFullMonth

One note, Crystal calculates all of these periods based on the print date which is normally the system date of your computer. But Crystal also allows you to override the system date for any report. Just go to [Report > Set Print Date] and you can pick another date. Just don’t forget to reset the date before you save the report or Crystal will continue to use that same date (for this report) until it is reset.









Leave a Reply

Jeff-Net
Recrystallize Pro

Crystal Reports Server