Crystal reports: using summary field in formula / summing time field in formula

jorrebor picture jorrebor · Oct 12, 2011 · Viewed 12k times · Source

In crystal reports I want to show the sum value of time objects, i.e. An employee worked in one month three days and on each day a variable amount of hours.

Is there anyway to sum a time field?

Or as a workaround I could use the time field as an integer, sum this and display. But then I would like to change the display format by using a formula. I cant find a way to include summary fields in a formula...

Thanks in advance

PS I am using CR 2011 (just the program not through VB or anything).

Answer

Ryan picture Ryan · Oct 12, 2011

You cannot sum a date/time field. You will have to use datediff("n",{datetime1},{datetime2}) to get a time interval between two date/time fields in minutes.

To use a summary function in a formula, you can use this sum({@YourMinutesFormula},{FieldYouAreGroupingOn})

You may omit the second parameter if you want the summation over the entire report instead of a grouping level. Check the Crystal Reports help file for more details on Sum().