Jean Carlo
Jean Carlo

Reputation: 37

Crystal reports 2011 formula to calculate a time interval and divide it

I need a help, I need to calculate an interval of time in 1 hour and divide your result by 12.

I have a table in my database that receives data from date and time and a value field in a cycle of 5 minute in 5 minute cycle I have 12 values ​​in 1 hour. I need to sum ​​the values ​​of this period of 1 hour and divide its value by 12.

How could I do this using a formula of the crystal 2011? was trying to use the DateDiff passing a parameter interval of time to filter, but I had no success.

My parameter using the type Date and Time, Static, Allow range values​​.

DateDiff ("h", {TB_Dados.Timestamp}, {?MyParameterDateRange})

thank you.

Upvotes: 0

Views: 1970

Answers (1)

Beth
Beth

Reputation: 9607

You'll need to group your timestamps by hour. Extend your datasource to include a field you can use to group by the timestamp's hour, something like yyyymmddhh. All the timestamps with that same value (up to 12, in your case) need to be summed, then you can average them by dividing by 12, or using an aggregate function.

Upvotes: 1

Related Questions