There are two ways to use today’s date in a Crystal formula. These are useful when you want the report to automatically determine a date range, like the last three days. You can calculate the date for three days ago by using one of the following calculations:
CurrentDate - 3
DataDate - 3
These expressions will generate the same value at the time the report is refreshed. But if you interact with reports after refreshing them, or if you open reports with saved data, it is important to know how these functions differ.
CurrentDate is identical to the functions PrintDate and Today. PrintDate is also a special field. These date function will all update whenever one of three things happens. When the report is:
2) previewed after a modification.
Interestingly, exporting a report to a PDF does NOT update these dates.
DataDate is a function and is also a special field. These are updated when the the report is refreshed.
So lets say I ran a report yesterday, saved it with data yesterday and then reopened it today without refreshing it. The CurrentDate function will show today’s date while the DataDate function will show Yesterday’s date.
You can see how these functions could affect record selection. If I calculate criteria to include the last 3 days using the CurrentDate function, and then reopen the report later with saved data, the CurrentDate will change and so will the criteria. The saved data will be reduced or eliminated. However, if I wrote the same criteria using DataDate there is no change because I have not refreshed the report. So when deciding to use one of these functions you should think about how the formula should respond when you reopen the report with saved data. If it should use date when the report is opened then use CurrentDate. If it should use the date when it was refreshed then use DataDate.
Also note that there are corresponding time functions (CurrentTime, PrintTime) and special fields that have the same names. The time functions follow the same pattern as the date functions.(For examples of my most popular formulas, please visit the FORMULAS page on my website.)