BusinessObjects Board

Can I create a Variable, and use a Function?

Can I create a variable and use a Function of some sorts to return the number of hours between two given dates ? If so, what function do I use ?
I did see a daysbetween, but I need to pass time also. I am developing using FullClient. Thanks.


DWP (BOB member since 2003-02-25)

As of v5 there is no straight forward way to get the no of hours between two dates, unless you store the timestamp also in the database and create a complex substring function in BO to compute the number of hours.


Anjan Roy (BOB member since 2002-07-10)

One possible workaround in BO Reporter:

A) Parse out the time part of your 2 dates (FormatDate, SubStr), convert it into hours or minutes etc. (ToNumber), subtract the hours from each other.

B) Use the DaysBetween function and multiply your result by 24 (to get hours) or by 24*60 to get minutes etc.

Add A) to B)

Or if you cannot do it in BO Reporter, create a Time Difference object in BO Designer using DB functions…


Andreas :de: (BOB member since 2002-06-20)

I’ve got an extension dll which I wrote which provides two functions.

datediff(date1, date2) - return the difference between two dates in days, it includes a fractional part to give you the difference in hours/mins etc. Appologies to Sybase/MS Sql users for the use of the function name I’m afraid it isn’t as flexible as the real thing

formatastime(seconds) - returns a character string H:M:S of the number of seconds converted to hours:mins:seconds. It doesn’t accumulate to days, but will report it as 48 hours for two days.

If anybody wants it just drop me an e-mail. Copy the dll to you userlibs directory and restart BO. The formatastime funciton is fairly extensivley tested, the datediff function less so, as we harly ever use it. If there is a lot of interest I’ll see if Dave can get it put on the Integra web site, or maybe there is even somewhere on BOB.

So to get what you want datediff(date1, date2)*24


ken.gaul :uk: (BOB member since 2002-06-18)

[quote:7285652cb5=“ken.gaul”]If anybody wants it just drop me an e-mail. Copy the dll to you userlibs directory and restart BO. The formatastime funciton is fairly extensivley tested, the datediff function less so, as we harly ever use it. If there is a lot of interest I’ll see if Dave can get it put on the Integra web site, or maybe there is even somewhere on BOB.

So to get what you want datediff(date1, date2)*24
[/quote]

Ken:

Please email your dll to bobdownloads@forumtopics.com and we’ll get it set up for folks to download here on BOB. Thanks. 8)

Dave


Dave Rathbun :us: (BOB member since 2002-06-06)