US and Worldwide: +1 (866) 660-7555
+ Reply to Thread
Results 1 to 3 of 3

Thread: Summing a time (duration)

  1. #1
    Join Date
    Jan 2006
    Posts
    298

    Default Summing a time (duration)

    I need to make a simple report that show the duration of an event and sum it per day.

    To display the the duration of the individual events in the item band is no problem. The problem is to sum the durations.

    The type of duration in the database is time (MySQL).

    I have tried summing the duration values, but apparently the ItemSumFunction cannot handle the summing.

    So i converted the time to an integer, made the sum using the ItemSumFunctio, but now i don't know how i can reformat it to show like 'hh:mm:ss'

    Can anyone help?

  2. #2
    Join Date
    Oct 2007
    Posts
    234

    Default

    Hi Begunrom

    I have had to do the same thing, what I did was have two columns, one to show the value in HH:MM:SS which I used for the value of the column then I had another one with just the seconds which I summed up for the total

    The displayed version of the total was then run through a BSH expression (Knowing my history of these there is a better way to do this)

    Code:
            Object getValue()
            {
            Number Duration = (Number) dataRow.get("Summary_minutedurationExpression"«»);
            
            if ( (Duration == null) || (Duration.doubleValue() == 0.0) )
              return new String("--:--:--");
            
           Integer hours = new Integer( (Duration.intValue() / 3600)); 
           Integer minutes = new Integer( ((Duration.intValue() % 3600) / 60));
           Integer seconds = new Integer( ((Duration.intValue() % 3600) % 60));
            
            String hhmmss = new String(hours.toString() +":"+minutes.toString()+":"+seconds.toString());
            return(hhmmss);
            }
    Hope this helps and also kind of hoping some one comes in with a better way to do it

    Wil

  3. #3
    Join Date
    Jul 2007
    Posts
    1,213

    Default

    http://pedroalves-bi.blogspot.com/20...d-control.html

    edit: Will got there first, but I have pictures
    Pedro Alves
    Meet us on ##pentaho , a freenode irc channel

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts