Question

i'm using Crystal Reports and I have an output like this (group by day):

(This output calculation is from 00:00 to 23:59 each day..)

  Date (dd/mm/yyyy)     Weight
   -----------------------------------------
    01-01-2013            4000
    02-01-2013            3000
    03-01-2013            6000
    04-01-2013            5000

How can I make it by time range like 01-01-2013 6:00AM to 04-01-2013 6:00AM and the output still as per day: (I pretend the half of current day + half of the next day)

  Date (dd/mm/yyyy)     Weight
   -----------------------------------------
    01-01-2013            3500 ( =half of 01-01-2013 and 02-01-2013)
    02-01-2013            4500 ( =half of 02-01-2013 and 03-01-2013)
    03-01-2013            5500 ( =half of 03-01-2013 and 04-01-2013)
    04-01-2013            2500 ( =half of 04-01-2013 and so on..)

Thanks,

Was it helpful?

Solution

You'd want to check the time whether it's before or after 12:00 noon. If it's 11:59:59 or less, add it to the previous day. Anything after, current day. Create a formula using something like this

    IF TIME({yourdatetime}) <= TIME(11,59,59) THEN
       DATE({yourdatetime}) - 1
    ELSE 
       DATE({yourdatetime})

Then group by the formula and format the group header for just the date.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top