Working with time interval

Comments

1 comment

  • Avatar
    Gowtham Senthilkumar

    Nishya, 

    In this case, to do any type of arithmetic operations, the final step is to convert the time interval which is in multiple units ('x' days 'y' hours 'z' minutes 'a' seconds) into the lowest possible unit which is seconds. After that, we could divide that value by 60 to get interval in minutes or divide by 3600 to get interval in hours. If you want to get interval in days (for ex: 3.14 days), then divide by 86400. 

    To achieve that, we should parse the string using the string functions that we have with Sisense. Let us assume that the column you have is name [time_interval].

    Converting to seconds: 

    ( strparts([time_interval], ' days ', 1) * 86400 ) +

    ( strparts( ( strparts([time_interval], ' days ', 2) ), ':' , 1) * 3600 ) +

    ( strparts( ( strparts([time_interval], ' days ', 2) ), ':' , 2) * 60 ) +

    ( strparts( ( strparts([time_interval], ' days ', 2) ), ':' , 3) )

    Hope this help! 

    Thanks, 
    Gowtham Senthilkumar

    0
    Comment actions Permalink

Please sign in to leave a comment.