A number of clients have asked me the same question recently, "How do I display the difference between two date-times fields, in hours and minutes, in Crystal Reports?"
Solution:
This is more easily accomplished using the "Display String" of the field
in question.
- Create the formula to calaculate the difference between the two date-time fields, in minutes
- Add the formula field to the report
- Right click on the field
- Select the Format Field menu option
- In the Format Editor dialog box, click on the Common Tab
- Click on the X+2 button to the right of Display String format option
- Enter the following formula :
NumberVar Hrs := Truncate(CurrentFieldValue/60);
Numbervar Mins := Remainder(CurrentFieldValue,60);
Totext(Hrs,0) + " Hrs " + ToText(Mins,0) + " Mins"
- Press the OK button
If you have any questions, leave us a comment below, or need any assistance, please do not hesitate to Contact Us
|