TimeStampDiff

Hello experts,
I want to know How to use TimeStampDiff function appropriately.
My requirement is I have a column in the physical layer say time. It is of datatype varchar(5). It stores the values in HH:MM format.
I want to have the difference between the current time and this column.
For current time, Im using function in OBI Answers: CURRENT_TIME(2) where 2 denotes the precision of seconds.
The formula Im using is TIMESTAMPDIFF(SQL_TSI_MINUTE, CAST("Query Time".Time AS TIMESTAMP), CURRENT_TIME(2)).
This is throwing the following error:
ORA-01843: not a valid month at OCI call OCIStmtExecute: select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, D1.c4 as c4, D1.c5 as c5, max(D1.c6) over () as c6 from (select distinct D1.c2 as c1, D1.c3 as c2, D1.c4 as c3, TO_DATE('1900-01-01 03:54:07' , 'YYYY-MM-DD HH24:MI:SS') as c4, D1.c1 as c5, D1.c1 as c6 from (select max(T45654.TOTAL_TIME_SEC) as c1, TRUNC(T45677.DAY_DT) as c2, ROUND( ( TO_DATE('1900-01-01 03:54:07' , 'YYYY-MM-DD HH24:MI:SS') - CAST( cast(T45654.START_HOUR_MIN as DATE) as DATE) ) * 1440 ) as c3, T45654.START_HOUR_MIN as c4 from S_ETL_DAY T45677, S_NQ_ACCT T45654 where ( T45654.START_DT = T45677.DAY_DT and T45654.SAW_SRC_PATH = '/shared/PI BOOK of Business - P2/AE Home Page/Search/P2 - Trust Request' and TRUNC(T45654.START_DT) = TO_DATE('2009-03-09' , 'YYYY-MM-DD') and TRUNC(T45677.DAY_DT) = TO_DATE('2009-03-09' , 'YYYY-MM-DD') ) group by T45654.START_HOUR_MIN, TRUNC(T45677.DAY_DT) ) D1 ) D1 order by c1 desc, c2, c3, c4. [nQSError: 17011] SQL statement execution failed. (HY000).
Can anybody help me get the right formula?
thx,
parag

Hi.
I try the similar:
TIMESTAMPDIFF(SQL_TSI_MINUTE, CAST('14:22' AS TIMESTAMP), CURRENT_TIME(2))
and I got an error:
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1843, message: ORA-01843: not a valid month at OCI call OCIStmtExecute: select distinct D1.c1 as c1, ROUND( ( TO_DATE('1900-01-01 12:05:33' , 'YYYY-MM-DD HH24:MI:SS') - CAST( cast('14:23' as DATE) as DATE) ) * 1440 ) as c2 from (select distinct T21473.PROD_CATEGORY as c1 from PRODUCTS T21473 ) D1 order by c1, c2. [nQSError: 17011] SQL statement execution failed. (HY000)
So the syntax is:
TimestampDiff (interval, timestamp-expression1, timestamp-expression2)
If you harcode it:
Timestampdiff(SQL_TSI_MINUTE, TIMESTAMP '2009-04-28 12:00:00', current_timestamp)
The results is difference in minutes.
So you just need to put 'the right expression' in the second place. Try to concatenate current date with your time value and place it insted of TIMESTAMP '2009-04-28 12:00:00' because this inputs only timestamp format.
Hope this helps.
Regards,
Goran
http://108obiee.blogspot.com/

Similar Messages

  • TIMESTAMPDIFF  function in OBIEE Answers

    Hi experts,
    I have a Answers report, where I have included a column and changing the fx formula to find out the time diff ..
    TIMESTAMPDIFF(SQL_TSI_DAY, "Bank Transactions - Payor Aging".AccountingDate, "Bank Transactions - Payor Aging".AccountingDate)
    here I want the second "Bank Transactions - Payor Aging".AccountingDate to be replaces with any date like as below
    TIMESTAMPDIFF(SQL_TSI_DAY, "Bank Transactions - Payor Aging".AccountingDate, '06/02/2010') for June-02-2010.
    But, the above date format is working... can any suggest what format I have give here to work.
    Thanks in Advance
    S

    Hi Madan...
    Thanks for the quick reply...
    I want to continue by next question on top of the TIMESTAMPDIFF function....
    TIMESTAMPDIFF(SQL_TSI_DAY, "Bank Transactions - Payor Aging".AccountingDate, TIMESTAMP '2010-06-02 00:00:00')
    how can I pass this part of the value from the Dashboard Prompt. I knew that the dashboard prompt can only be created on the presentation column. I can't put any date column in my datawarehouse datamodel as there is already one. I looking if there any other way of passing the second date value from the dashboard prompt.
    Thanks in Advance
    S

  • TimeStampDiff function ROUNDing the result. How can we avoid this?

    Hi,
    I am using the following timestamp function:
    TIMESTAMPDIFF(SQL_TSI_HOUR, "SF_CS_CS_Fact"."Crtddt_Dt", "SF_Emlmssg_Sum_CS"."Initl Resp Tm")
    I notice that the result set is rounded off to the whole no.
    This is happening because OBIEE autimatically ROUNDS the difference of the timestamps whe using TIMESTAMPDIFF:
    select distinct D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    D1.c9 as c9,
    D1.c10 as c10
    from
    (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    D1.c9 as c9,
    D1.c10 as c10
    from
    (select 0 as c1,
    D1.c4 as c2,
    D1.c5 as c3,
    D1.c3 as c4,
    D1.c2 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    D1.c9 as c9,
    D1.c1 as c10,
    ROW_NUMBER() OVER (PARTITION BY D1.c2, D1.c3, D1.c4, D1.c5, D1.c6, D1.c7, D1.c8, D1.c9 ORDER BY D1.c2 ASC, D1.c3 ASC, D1.c4 ASC, D1.c5 ASC, D1.c6 ASC, D1.c7 ASC, D1.c8 ASC, D1.c9 ASC) as c11
    from
    (select distinct ROUND ( ( CAST(T14421.INITIAL_RESPONSE_TIME as DATE)  - CAST(T14963.CRTDDT_DT as DATE)  ) 24 ) as c1*,
    T14963.CRTDDT_DT as c2,
    T14963.CSNMBR as c3,
    T4813.FISCAL_YEAR_NAME as c4,
    T4813.FISCAL_QUARTER_NAME as c5,
    T14421.INITIAL_RESPONSE_TIME as c6,
    T14468.GRP as c7,
    T4813.FISCAL_YEAR_ID as c8,
    T4813.FISCAL_QUARTER_ID as c9
    from
    DW_SF_EMLMSSG_SUM_CS T14421,
    DW_SF_EMLMSSG_CS T14400,
    SF_ORGN_CS_DIM T14468,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_CS T14963 /* SF_CS_CS_Fact */
    where ( T14400.PRNTID = T14963.ID and T4813.CALENDAR_KEY = T14963.CRDT_KEY and T14421.PRNTID = T14963.ID and T14400.STTS = '3' and T14468.ORGN_KEY = T14963.ORGN_KEY and T14963.TYP = 'CIN' and (T14963.CSNMBR in ('1103676964', '1103677035', '1103677076', '1103677285', '1103677303', '1103677369', '1103677389')) )
    ) D1
    ) D1
    where ( D1.c11 = 1 )
    ) D1
    order by c1, c8, c9, c7, c4, c5, c6, c10
    Please see the line in Bold in the query.
    I want to get the results in the actual decimal point and not the whole no. Is there a way that I can enable the TIMESTAMPDIFF not to ROUND by default.
    Any answers will be helpful.
    Thanks,

    When you specify in the interval in the first argument of TIMESTAMPDIFF you are implicitly telling OBIEE the level of precision that you want. For SQL_TSI_YEAR you are going to get integer values of whole years. if yo uneed to get more granular than that you need to use SQL_TSI_MONTH or WEEK.
    Also note, than when performing mathematical operations like divide an multiply, all elements of the calculation need to be a data type that can represent decimal values, or the result of the entire calc will always get converted to an integer.

  • TIMESTAMPDIFF function in combined analysis

    Hello,
    Has anyone used the timestampdiff function in a combined analysis? I have created a combined analysis with using two subject areas and tried using the timestampdiff function in the results section but its not giving me the right results. I am using timestampdiff(sql_tsi_day, saw_5, saw_3).
    Any help is appreciated.
    Thanks!
    Sonia

    I guess you can use TIMESTAMP functions in result columns. The only case where you may hit an error is when one of the columns(say saw_5) is having a null/blank value for the corresponding value in saw_3.

  • Subtracting Datetime using timestampadd or timestampdiff in Obiee

    Hi,
    I am trying to subtract the current date to the date i need without using between in the filters but using TIMESTAMPADD OR TIMESTAMPDIFF
    For ex
    From: 12/01/2013
    TO:    12/07/2013
    so i want only those records to be shown (between those records as well as the start date and end date)
    Thank you,

    So what's your problem using TIMESTAMPDIFF?
    TIMESTAMPDIFF(SQL_TSI_DAY, Time."Day Date", CURRENT_DATE)

  • Working/Business Days with TimeStampDiff

    Hi,
    Background: I have an order table with a set of possible statuses. There also exists an audit trail that has a timestamp for when a certain status is set.
    Customer wants to measure between two different statuses - which is no problem with a timestampdiff between the two. However, there is also a need to subtract any day classified as a non-business day that falls between the two dates. What i've created is a table that contains the dates that are non-business days. In SQL, i would do this by doing the timestampdiff, then subtracting the count of days that falls between the two dates in the timestampdiff.
    The problem comes when i try to express this in the business model... I can of course do the timestampdiff, but i cannot seem to find a way to do the count of the days in the exception table. Anyone have an idea of how to solve this?

    The easiest way that i can think of is to have a database function created within the database which would accept the 2 dates as parameters and would return the count. Use EVALUATE to call the database function. Use my blog entry here http://oraclebizint.wordpress.com/2007/09/10/oracle-bi-ee-10133-support-for-native-database-functions-and-aggregates/ which would give you a basic idea of calling the database functions.
    Thanks,
    Venkat
    http://oraclebizint.wordpress.com

  • Problem with TIMESTAMPDIFF

    I have this issue.
    I write this formula for a REPORT in a column and there aren't problems.
    CASE WHEN YEAR( "- Service Request Custom Attributes".DATE_6) =YEAR( "- Service Request Custom Attributes".DATE_7) AND WEEK_OF_YEAR( "- Service Request Custom Attributes".DATE_7)> WEEK_OF_YEAR( "- Service Request Custom Attributes".DATE_6) THEN 'iii' ELSE 'aaa' END
    I also write this formula in a new column and there aren't problems.
    TIMESTAMPDIFF(SQL_TSI_HOUR, "- Service Request Custom Attributes".DATE_6, "- Service Request Custom Attributes".DATE_7)
    Now i write this formula and when i click OK is dispayed a ERROR MESSAGE.
    CASE WHEN YEAR( "- Service Request Custom Attributes".DATE_6) =YEAR( "- Service Request Custom Attributes".DATE_7) AND WEEK_OF_YEAR( "- Service Request Custom Attributes".DATE_7)> WEEK_OF_YEAR( "- Service Request Custom Attributes".DATE_6) THEN TIMESTAMPDIFF(SQL_TSI_HOUR, "- Service Request Custom Attributes".DATE_6, "- Service Request Custom Attributes".DATE_7) ELSE 'aaa' END
    Why ?
    ERROR
    [nQSError: 10058] A general error has occurred. [nQSError: 22027] Union of non-compatible types. (HY000)........................
    Thank you!
    Vale

    Hi Vale,
    Just looking at the first 2 formulae and not the combined you populating different data types with your case statement from the Timestampdiff.
    Your case statement generates a string response where as the Timestampdiff generates an integer. Try replacing in your Else statement '1' or '0' to counter the timestampdiff instead of 'aaa'
    Regards
    Mike

  • OBIEE timestampdiff function syntax error

    Hi all,
    I am getting an error while applying timestampdiff function .help me to sort it out.
    TIMESTAMPDIFF(SQL_TSI_DAY,"- Sanction and Disbursment"."Value Date" , VALUEOF(NQ_SESSION.VAR_CAL_CURR_DATE))
    error details
    Formula syntax is invalid.
    [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 22025] Function TimestampDiff is called with an incompatible type.Please have your System Administrator look at the log for more details on this error. (HY000)
    SQL Issued: SELECT TIMESTAMPDIFF(SQL_TSI_DAY,"- Sanction and Disbursment"."Value Date" , VALUEOF(NQ_SESSION.VAR_CAL_CURR_DATE)) FROM "SIDBI Master"

    Aswin,
    Syntax looks to be fine but before applying it here can you check if both these 2 parameters returns date in same format:
    "- Sanction and Disbursment"."Value Date" = 08/21/2011 (No Timestamp)
    VALUEOF(NQ_SESSION.VAR_CAL_CURR_DATE) = 08/21/2011 (No Timestamp)
    Both shud have same format.
    Also, try this for verification
    TIMESTAMPDIFF(SQL_TSI_DAY,"- Sanction and Disbursment"."Value Date" , CURRENT_DATE)
    Hope this helps

  • Using TimeStampDiff

    Have a customer who want to see the total time spent in a location by location - I have the enter time and the exit time (both timestamps) and am able to calculate the difference using TimeStampDiff, however I want to create an aggergration on the total time by location? I can get the individual transaction time difference but can not figure out how to aggergrate these individual transactions together to get a "sum of time" by location?
    Any suggestion?

    Hi,
    Try this............
    sum(TIMESTAMPDIFF(interval, tablename.entry_time, tablename.exit_time) by tablename.location)
    The specified interval. Valid values are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR
    Cheers,
    Aravind

  • Calendar - timestampDiff

    hi,
    i've read a lot of threads about calendar(in dashboard prompt) and timestampdiff.
    i have the following question.
    I want to have the periods of days for 2 periods of time-select by calendar in dashboard
    --->
    i created 4 prompts in dashboard prompts using in formula
    CASE WHEN 1=0 THEN "Calendar"."date" ELSE TIMESTAMP '2200-01-01 00:00:00' end(this column is timedate in oracle 10gr2)
    i changed for each the ..01-02 00:.... , an i set 4 presentations variables (dstart1,dstart2,dend1,dend2)
    Then i want to have 2 columns with the period of the days selected before.
    --->>>
    So,i created 2 columns with the following code :
    timestampdiff(sql_tsi_day,'@{dstart1}','@{dend1}')
    timestampdiff(sql_tsi_day,'@{dstart2}','@{dend2}')
    and i added the quantity in a pivot table to see the specified quantity for these 2 periods.
    The question...
    The function timestamp does not recognize the '@{dsrat1}' as timestamp , how can i achieve it?
    I tried timestamp'@{dstart1}' , with no result.
    I have to change the type for my column in adminstrator as 'timestamp"?
    i have to make a new logical column with timestamp??
    Any ideas?
    tnks,for ur time...

    it works for drop-down list
    but not for calendar.
    any other ideas?
    i have to "cast" in some way my 4 presentaions variables which come from dashboard calendar to "format" which is accepted by the function timestampdiff.
    tnks again 4 ur time.

  • Emulating TIMESTAMPDIFF

    I'm new or Oracle and am trying to emulate the JDBC function TIMESTAMPDIFF(interval, timestamp1,timestamp2). This function returns an integer which represents the number of intervals by which timestamp2 is greater than timestamp1. The interval may be set to SECONDS,MINUTES,HOURS,WEEKS,MONTHS,QUARTERS, or YEARS. Anyone have any ideas?

    Duplicate thread. Please only post once.
    Error in function

  • Timestampdiff() function: result in  millisecond

    Hello,
    I'm using the OBIEE timestampdiff() to calculate the difference between two timestamps, before to continue to use this function I want to check if the function can calculate the delay in second and give result like this example:
    TIMESTAMPDIFF(SQL_TSI_SECOND, CAST("LOGFILE_VORDEL"."DATE_HOUR" as timestamp),CAST("LOGFILE_VORDEL_S"."DATE_HOUR" as timestamp))=19,23 sec
    which mean
    19 Second and 23 Millisecond.

    try to make it informatica. not sure obiee can support to_date function where you can get date format in milliseconds.

  • TIMESTAMPDIFF in rpd level

    Hi,
    can i able to user TIMESTAMPDIFF forumula in rpd level as a logical table source formula in logical column
    thanks

    Hi,
    Yes you can.The function is available under CalendarDate/Time Functions in the Expression builder dialog.
    Rgds,
    Dpka

  • TIMESTAMPDIFF calculation in Teradata & Oracle

    Hi All,
    I'm using OBIEE 10.1.3.4 version.
    I have noticed difference in the calculation of TIMESTAMPDIFF (SQL_TSI_WEEK) when connecting to Teradata & Oracle as Warehouse DB.
    The diff is in the way the rounding is done.
    Has anyone seen similar behaviour, if yes then is it known issue & is there any solution to it?
    Regards,
    Priti

    Field A and B are both numbers.
    I also aware of '0' problem and I have already define it (ifnull (xx,0) ) from answers.
    Finally, I use this to make it done:
    <?xdoxslt:div(sum(current-group()/_BE_measures_._GROSS_SALES_) - sum (current-group()/_IFNULL__BE_measures_._TOTAL_COST___0_), sum(current-group()/_BE_measures_._GROSS_SALES_)) * 100 ?>
    I wonder why I can't use simply "div" nor "xdofx" to archieve this....
    Thanks all anyway ~

  • TimeStampDiff Function

    Hi Guys,
    I have an function that says calculate the difference in Months between the opportunity expected close date and Today's date
    Timestampdiff(SQL_TSI_MONTH,Current_Date,"Close Date".Date)
    Today is the 8th December.
    My report shows:
    Close Date:.................. 23-Nov-10
    Months Difference:........ -1
    Close Date: ................. 24-Nov-10
    Months Difference: ......... 0
    But i think any date in November should be '-1' months difference from today.
    Anyone know why this shows 0
    Thanks
    Minesh

    Duplicate thread. Please only post once.
    Error in function

Maybe you are looking for

  • How do I send invoices to a different account?

    Hi, how do I forward invoice emails to my accountant without changing our primary account email?

  • How to use MAX() function with date field

    Hi Frzz, I have created a Graphical calculation view in which i have multiple records for each employee with different dates. But my requirement is to take the records which have maximum date. I have converted the date into Integer and applied the MA

  • Get image of Data Type of wire

    Hello,  I know how to return the image of a front panel or diagram using VI server however I'm looking to be able to return the same image as displayed within the 'Data Type of Wire' information in the Context Help window when I hover my mouse over a

  • Remote Agent for ACS for Windows 2008 R2 64-bit

    Hi, We having difficulties with installing remote agent on windows 2008 R2 64-bit server and got the attached error. Our ACS is 4.2.0.124 and remote agents we tried are :Remote-Agent-ACSse-win-v4.2.1.15-K9.zip and Acs-4.2.1.15.9-RA.zip. I see followi

  • Types Of Special Stocks and Inforecords.

    Hi All Thanks for the help being done. What are the types of special stocks available? What are the types of inforecords? Vineeth.