Thursday, December 14

Calculations With Dates

Google+ Pinterest LinkedIn Tumblr +

Many functions arc available to use with date fields. In your sample report you want to calculate the number of days it took for each order to be pro­cessed. Write a formula named “Processing Days” to subtract the Ship Date from the Order Date and insert the formula field into group header #3.

It is possible to insert this formula into either the group W3 header or footer sections, because It Is calculating the processing days for each Order ID. If you place the field In the details area, it will just list the same number for each detail line. The calculation will still be correct, but the value repetitive and possibly confusing on the report.

This formula returns the difference in days between the two dates, such as | “1.00” for one day, “2.00” for two days, and so on. When SCR pulls date fields from your database, it converts them to its own format so that dates can be easily compared with one another and used with the date functions SCR provides. This formula returns a number, and so it (by default) has two deci­mal places (1.00, 2.00, and so on). You may want to format the field to remove the decimals using the Format Editor or .the Remove Decimal button on the Formatting toolbar.

Another example involving dates uses the current date function. Let’s say you want your report to calculate how many days ago orders were placed. Create a new formula and name it “Days since Last Order”. You can insert this formula into either group header or footer #3.

Current Date – (Orders. Order Date!

This formula subtracts the order date from the current date and returns a number of days. The current date comes from your computer’s system clock. You could use this type of formula within an if-then-else statement, so that depending on the outcome of the formula something would occur or print on the report. The formula “Payment Flag” in the if-then-else section<4ater in this chapter will do just that.


About Author

Leave A Reply