BusinessObjects Board

Date Calculation Error

I created two objects in the universe for calculating Time Elapsed. The trouble is that the objects are parsing alright but, when I create a variable - , I get a type mismatch error! Both the objects are dates.

Date1

SELECT cast(max(SUDB_View.SUDBA18_MSG_DAILY.OPER_PARAM_ONE_X) as time)

WHERE
SUDB_View.SUDBA18_MSG_DAILY.DLR_DEALER_CODE_C = 'BEGIN'
 AND 
SUDB_View.SUDBA18_MSG_DAILY.MSG_NUM_C >= 9000

And Date 2 is

SELECT cast(max(SUDB_View.SUDBA18_MSG_DAILY.OPER_PARAM_ONE_X) as time)

WHERE
SUDB_View.SUDBA18_MSG_DAILY.DLR_DEALER_CODE_C = 'END'
 AND 
SUDB_View.SUDBA18_MSG_DAILY.MSG_NUM_C >= 9000

Any suggestions?
[/code]


Bharat :india: (BOB member since 2004-05-03)

You can’t do date arithmetic like this in BO. You need to use daysbetween(), but that only has a precision of 1 day. Alternatives are
[list]Creating the difference object in the universe using native DB functions
using the DLL add-in here and using the datediff function that provides. (go here for a version 6 version ( which nobody but me has vierified yet)
Creating the objects as non-date/time and using seconds since the date X and then normal subtraction will work.
[/list]
I’m sure there are other ways maybe a search or too might help, this sort of thing is covered many times over.


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

One more point is if you have put those conditions in the WHERE clause of the object definition then you will get no data since the conditions


SUDB_View.SUDBA18_MSG_DAILY.DLR_DEALER_CODE_C = 'BEGIN'

SUDB_View.SUDBA18_MSG_DAILY.DLR_DEALER_CODE_C = 'END'

mutually exclude each other and you will not find record matching that condition… As a best practice one should avoid putting conditions in the Object definition as this may interfere with the conditions of another object… Alternatively you can setup a view with the necessary SQL thats gives you the difference…


Sridharan :india: (BOB member since 2002-11-08)