US and Worldwide: +1 (866) 660-7555
Results 1 to 8 of 8

Thread: how to convert seconds to Time in format hh:mm:ss using MDX

  1. #1
    Join Date
    May 2014
    Posts
    11

    Default how to convert seconds to Time in format hh:mm:ss using MDX

    I have a measure as Integer (it is seconds) and i would like convert this second in the format hh:mm:ss
    it works with function Sec_to_time in query of mysql but MDX???

  2. #2
    Join Date
    Jan 2013
    Posts
    552

    Default

    A custom formatter is probably your best bet. Maybe something like:

    <Measure name="Seconds" column="seconds"
    aggregator="sum" >
    <CellFormatter>
    <Script>
    var date = new Date(value * 1000);
    return date.getUTCHours() + ":" + date.getUTCMinutes() + ":" + date.getSeconds();
    </Script>
    </CellFormatter>
    </Measure>

  3. #3
    Join Date
    May 2014
    Posts
    11

    Default

    it doesn't work
    it returns sum of seconds but not hh:mm:ss

  4. #4
    Join Date
    May 2014
    Posts
    11

    Default

    it doesn't work.
    it returns sum of seconds but not hh:mm:ss

  5. #5
    Join Date
    Jan 2013
    Posts
    552

    Default

    What version of Mondrian are you running?

  6. #6
    Join Date
    May 2014
    Posts
    11

    Default

    mondrian 3.2

  7. #7
    Join Date
    Jan 2013
    Posts
    552

    Default

    Support for scripts in the schema didn't exist in 3.2. I believe you should be able to create a Java class to do the formatting, however. See details at http://mondrian.pentaho.com/document...Cell_formatter.

  8. #8
    Join Date
    May 2014
    Posts
    22

    Default

    return Math.floor(value/3600) + ":" + ("0"+Math.floor((value-(Math.floor(value/3600)*3600))/60)).slice(-2) + ":" +("0"+(value-Math.floor(value/3600)*3600-(Math.floor((value-(Math.floor(value/3600)*3600))/60)*60))).slice(-2);

Posting Permissions

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