BusinessObjects Board

calculate difference between two times in webi

Hi All

I want to calculate the difference between two times in report level.

For example:4:00 to 4:20
I need to show the difference between the two times is 20 minutes in the report.How can i achieve the same?

I tried to find in BOB forums but they used dates and calculated the difference of time in Deski.

Please help to create a variable at report level in Webi.

Thanks in advance.I appreciate your work.


passport (BOB member since 2010-05-07)

= 
(
 ( 
 ( 
 ToNumber( Substr( FormatDate( [Most recent timestamp] ;"HH:mm:ss" ) ; 1 ; 2 ) ) * 60 * 60 +
 ToNumber( Substr( FormatDate( [Most recent timestamp] ;"HH:mm:ss" ) ; 4 ; 2 ) ) * 60 + 
 ToNumber( Substr( FormatDate( [Most recent timestamp] ;"HH:mm:ss" ) ; 7 ; 2 ) )
 ) 
 - 
 (
 ToNumber( Substr( FormatDate( [Oldest timestamp] ; "HH:mm:ss" ) ; 1 ;2 ) ) * 60 * 60 +
 ToNumber( Substr( FormatDate( [Oldest timestamp] ; "HH:mm:ss" ) ; 4 ; 2) ) * 60 +
 ToNumber( Substr( FormatDate( [Oldest timestamp] ; "HH:mm:ss" ) ; 7 ; 2) )
 )
 )
) / 60 +
( DaysBetween( [Oldest timestamp] ; [Most recent timestamp] ) * 24 * 60 )

mikca :australia: (BOB member since 2005-12-16)

Thanks a Ton…That worked…You are awesome…!!!


passport (BOB member since 2010-05-07)

Thanks so very much!
I had the same kinda issue,your formula worked great!


heyyin (BOB member since 2010-12-14)

It is a formula that I found on BOB so gratitude to original author whose name I lost :frowning:

I find it strange that BO does not have a built in TimeStamp_Diff routine

Mick


mikca :australia: (BOB member since 2005-12-16)

Yeah Man, i am new to WEBI and i wasted some time writing something to it…
hope the next realease has it.


heyyin (BOB member since 2010-12-14)

Desperately needed this and very glad I came across this post. Thanks!


steph m (BOB member since 2008-04-11)

THIS May be the answer I have been looking for…or at least on the right track.

I changed the names of the fields to match my fields. [Start Time] would replace [oldest time stamp] and [End Time] would replace [Newest Time Stamp]? Right?

And if the time is labeled as a text column, how can I change it? It will not let me select any number options in the format cell menu.

I have spent hours to get a duration, and finally found this forum, so I am really hoping you can help!

THANK YOU!!!


bmorehappy (BOB member since 2012-06-23)

If your timestamp is already a text field then you can remove all of the FormatDate routines (which only exist to turn timestamps to strings) and use appropriate ToNumber( Substr( [Your datetime field value]; n; m) ) routines to extract the values you want.

Mick


mikca :australia: (BOB member since 2005-12-16)

:smiley: Thanks


cheedalla (BOB member since 2004-04-13)

4.2 SP5 has new inbuilt functions for calculating time differences


jemstar :ireland: (BOB member since 2006-03-30)