BusinessObjects Board

Diff between two dates

I am trying to create a variable in Desktop Intelligence XI that will give me the diff between two dates. I used “=DaysBetween(<Admit Date & Time> ,<Order Date & Time>)” and I get just days. Is there a way to get his broke down to hours, minutes and seconds?


djohnson :us: (BOB member since 2007-07-26)

Date difference in minutes
difference between dates
Time difference
Subtract Dates at the report level
interesting average
Calculating the # of minutes between 2 datetime fields
Calculation of date and time difference with 4 number fields
Date/Time Difference?
Time difference between two dates
Hours Minutes Difference
Measring Time
Date difference in days, hours and minutes
How to identify time difference between two datetime fields
Time Between Submit date and Completed Date
Difference between two Dates
Number of hours between two dates
Calculate action difference
Note completed within 8 hours
Subtract Two dates with Timestamp Webi Report
hours or minutes between 2 date objects
Time difference between date between
Help
Difference between Two Datetime Field
trying to set up a elapse time between two dates
Displaying elapsed time in decimal hours
Time stamp diff to calculated in a variable
Variable help - Hours between 2 dates
Number of minutes between two times.
Milliseconds Calculation
Converting String Data Field to Show Difference In Seconds
Time Stamp Difference
Using Time within calculations
Elapsed time between 2 ddt fields
Need help with a formula
compare hours using days between
[solved] calculate time between two dates
Number of Hours calculation
Converting a time (number) measure to Days/hours/mins/secs
Assistance required for Basic user
Time difference
Date and Time Issue
how to minus objects
Differenc between 2 dates
date comparaison in webi report
Date Difference
Calculating difference between times..
Hours Between two Date/Times
Difference in seconds between Current Date/Time & Previo
days between does not take into consideration time stamp
Subracting Date/Time
Auditing Time Zone
Time Difference in Web Intelligence
Convert text to time, and do calculation
Calculating minutes between two datetimes
Difference between dates
Date Diff with AM/PM
Compare Dates in hours
Calculating duration in minutes between two date time stamps
Calculate Delivery time in DD:HH:MM
Time between two dates
difference in time error
Formula for time btwn dates worked b4, now incorrect. Help?

Unfortunately no, DaysBetween() function gives the result only in days.

A possible workaround would be to convert both dates to the numbers of seconds from some date&time in past (for instance January 1 2008 00:00:00) then do the difference of these 2 numbers (to get the difference between date1 and date2 in seconds) and then convert the result back to hh:mi:ss for instance.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

I am some what new to writing variables (no official trainng). Here is a variable I created but my numbers didnt look right…

=(((DaysBetween(<Admit Date & Time> ,<Order Date & Time>))*1440)+(ToNumber(SubStr(FormatDate(<Order Date & Time> ,“HH:mm:ss”) ,1 ,2)) -

ToNumber(SubStr(FormatDate(<Admit Date & Time> ,“HH:mm:ss”) ,1 ,2)))*48 +(ToNumber(SubStr(FormatDate(<Order Date & Time> ,“HH:mm:ss”) ,4 ,2)) -

ToNumber(SubStr(FormatDate(<Admit Date & Time> ,“HH:mm:ss”) , 4 , 2))))/60 :smiley:

I appreciate your help with this.


djohnson :us: (BOB member since 2007-07-26)

Hi,

Try the following:

  1. Create a report-level variable that calculates the number of seconds between 2 dates:
=DaysBetween(<ADMIT_DATE> ,<ORDER_DATE>) * 86400
 +
 (
   ToNumber(FormatDate(<ORDER_DATE> ,"HH")) * 3600 + 
   ToNumber(Left(FormatDate(<ORDER_DATE> ,"mm:ss") ,2)) * 60 + 
   ToNumber(FormatDate(<ORDER_DATE> ,"ss"))
 )
 -
 (
   ToNumber(FormatDate(<ADMIT_DATE> ,"HH")) * 3600 + 
   ToNumber(Left(FormatDate(<ADMIT_DATE> ,"mm:ss") ,2)) * 60 + 
   ToNumber(FormatDate(<ADMIT_DATE> ,"ss"))
 )
  1. Then use this formula to format the variable:
=FormatNumber(Floor(<number of seconds>/86400) ,"0") &amp; " day(s) " &amp;
FormatNumber(Floor(Mod(<number of seconds> ,86400)/3600) ,"00") &amp; ":" &amp;
FormatNumber(Floor(Mod(Mod(<number of seconds> ,86400) ,3600)/60) ,"00") &amp; ":" &amp;
FormatNumber(Mod(Mod(Mod(<number of seconds> ,86400) ,3600) ,60) ,"00")

Did it work?


Marek Chladny :slovakia: (BOB member since 2003-11-27)

I tried the variable and it did not work. I get the error not enough parameters.

I noticed my commands are Admit Date and time and Order Date and Time. So I changed it and I get another error. Incorrect Data type DMB0003. When I look at the variable it has the + highlighted. I will copy upto where it is erroring out.

=DaysBetween(<Admit Date & Time> ,<Order Date & Time>) * 86400
+
( ToNumber(FormatDate(<Order Date & Time> ,“HH”)) * 3600 +
ToNumber(Left(FormatDate(<Order Date & Time> ,“mm:ss”) ,2) * 60 + (here).


djohnson :us: (BOB member since 2007-07-26)

Then try this one:

=DaysBetween(<Admit Date &amp; Time> ,<Order Date &amp; Time>) * 86400 + ( ToNumber(FormatDate(<Order Date &amp; Time> ,"HH")) * 3600 + ToNumber(Left(FormatDate(<Order Date &amp; Time> ,"mm:ss") ,2)) * 60 + ToNumber(FormatDate(<Order Date &amp; Time> ,"ss"))) - (ToNumber(FormatDate(<Admit Date &amp; Time> ,"HH")) * 3600 + ToNumber(Left(FormatDate(<Admit Date &amp; Time> ,"mm:ss") ,2)) * 60 + ToNumber(FormatDate(<Admit Date &amp; Time> ,"ss")))

It is in fact the same formula but written in 1 line instead of more. I used more lines above for the formula be more readable.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

I hate to give good news and bad news in the same reply but… first thank you for your help.

It works great and all looks good. When I created the second variable i get an error message. "Not enough paramerters DMB0006 My curser starts flickering here

=FormatNumber(Floor(


djohnson :us: (BOB member since 2007-07-26)

How about the same without carriage returns (no extra “enters”):

=FormatNumber(Floor(<number of seconds>/86400) ,"0") &amp; " day(s) " &amp; FormatNumber(Floor(Mod(<number of seconds> ,86400)/3600) ,"00") &amp; ":" &amp; FormatNumber(Floor(Mod(Mod(<number of seconds> ,86400) ,3600)/60) ,"00") &amp; ":" &amp; FormatNumber(Mod(Mod(Mod(<number of seconds> ,86400) ,3600) ,60) ,"00")

Did you give the first variable the name “number of seconds”? If you used any other name then you need to change the above formula accordingly.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

OMG… You are the greatest! Thank you for all your help… If you havnt figured it out yet… it worked. :smiley:


djohnson :us: (BOB member since 2007-07-26)

Perfect 8) I am glad it helped.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

Hi

This has been fantastic advice and I have managed to recreate it for my use as specified. I have one question that puts a slightly different slant on it in that I would like to display my elapsed time in hours, minutes and seconds. Therefore if it goes over 24 hours, I’d still like my results to show something like 27:16:23. I don’t really understand Mod so any pointers would be really appreciated.


jmmorton :uk: (BOB member since 2004-07-05)

Hi Jonno,

Then try the formula from this post:


Marek Chladny :slovakia: (BOB member since 2003-11-27)

That’s fantastic - worked a treat. Thanks ever so much Marek.


jmmorton :uk: (BOB member since 2004-07-05)

Hi Mark,

I have similar problem. I tried your solution but it didn’t worked please help me.

I have 2 dates

  1. Submit date (dd/mm/yyyy hh:mm:ss)
  2. Responded date (dd/mm/yyyy hh:mm:ss)

User wants to know the response time in HH:MM:SS

the date in the data base is entered in UTC and we are using a custom function in oracle to extract date from that UTC in to BO based on time zone.

Help me with this as this is really imp…

Thanks in advance,

SAM


sam4u :us: (BOB member since 2008-01-09)

Hi,
when you said that you should have also said what the problem was, how it behaved. Did you get any error message or wrong results or…?


Marek Chladny :slovakia: (BOB member since 2003-11-27)

Hi Mark,

There was some syntax error ( missing paranthesis) i fixed it an finally it worked. Thanks for your response.


sam4u :us: (BOB member since 2008-01-09)

This is a very interesting article, many thanks for posting it however, is there an easy way to add a time field to a date field to give a date time field?

Regards

Paul


figdatbong :uk: (BOB member since 2008-03-27)

Hi,

This topic may help:


Marek Chladny :slovakia: (BOB member since 2003-11-27)

Hi Marek

I would like to thank you for submitting this and other related posts. Using them as a guide, I have been able to develop a solution that works i.e. determine whether contractors are meeting specified targets.

Many thanks

Regards

Paul


figdatbong :uk: (BOB member since 2008-03-27)

Hi Marek,

The solution with the formulae to the time difference worked out well.

You are brilliant. Thank you.


bobuser9 (BOB member since 2007-04-20)