Friday 21 April 2017

Crystal Reports : Displaying Hours and Minutes

Let us suppose we would like to summarize the amount of minutes in a phone call report, but express the grand total in hours and minutes. This is more easily accomplished using the "Display String" of the field in question. This allows us to create the summary field as normal.

1. Create a summary field to SUM your {CALLS.MINUTES} field
2. Right click on the summary field itself
3. Click on the "X-2"button to the right of "Display String"
4. Paste in the following formula :

local numbervar Hr := Truncate(CurrentFieldValue/60);

local numbervar Mn := Remainder(CurrentFieldValue,60);

Totext(Hr,0) + "Hours " + ToText(Mn,0) + "Minutes"

Pro Tip : The CurrentFieldValue function returns the current field value of the field being formatted. This allows easy code reuse.

No comments:

Post a Comment

Control Structures (Crystal Syntax) In Crystal Report : If Expressions (Crystal Syntax) in Crystal Report

Formulas without control structures execute each expression in the formula exactly once when the formula is evaluated. The expressions are...