How to calculate the month difference between two date char. in Query?

Customers would like to see how many months passed between two date type of characteristics (e.g., the month difference between the current date and the scheduled delivery date in the record) and put the result into the column as KF. 
We would have to grab the fiscal year/period kind of value and then do the subtraction, e.g., if the current date value is 2/28/2008 and the scheduled delivery date value in the record is 12/01/2007, the correct result should be 2 month difference between these two date values, but could someone here give us the technical light on how to make this happen in query design?
Thanks and we will give you reward points for the correct anwsers!

Hi Kevin,
The Badi is RSR_OLAP_BADI.
You can create an implementation using Transaction  SE18.
The implementation is per cube and is defined in the filters.
In the Implementation you have the following methods :
1. Define : Here you will provide the Keyfigure you need as a virtual one.
2. Initilialize : Any Init Function you want to do.
3. Compute. This is called per datarecord and here you can cimpute your value.
Hope this helps.
Pralay Ahluwalia

Similar Messages

  • How to calculate the hour difference between two dates?

    hi all,
    how to calculate the hour difference between two dates?
    eg i trying this...
    ((TO_DATE(TO_CHAR(GRNi.reference_date_4,'hh24:mi'),'hh24:mi') -
    TO_DATE(TO_CHAR(NVL(GRNi.reference_date_3,SYSDATE),'hh24:mi'),'hh24:mi'))*24)*60 Act_Hr
    Reg.
    AAK

    Hi
    To break the diff between 2 dates into days, hours, minutes, sec -- you can use the following:
    select to_char( created, 'dd-mon-yyyy hh24:mi:ss' ),
    trunc( sysdate-created ) "Dy",
    trunc( mod( (sysdate-created)*24, 24 ) ) "Hr",
    trunc( mod( (sysdate-created)*24*60, 60 ) ) "Mi",
    trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Sec",
    to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ),
    sysdate-created "Tdy",
    (sysdate-created)*24 "Thr",
    (sysdate-created)*24*60 "Tmi",
    (sysdate-created)*24*60*60 "Tsec"
    from all_users
    where rownum < 50
    HTH
    RangaReddy

  • How to calculate the phase difference between two square wave (acquired from two channel in one DAQ)

    Hello everyone ,
     I need a quickly help that as below :
    I am trying use PCI-6220 to acquired six signals from one rotation encoder (channel A, channel B,channel Z ,and their non-signals) .The encoder out signals will be square wave and 4000pulses per revolution. I set it rotation at 300rpm speed. I need show every square wave of six out channels in waveform and measure the A-B phase difference to check if the value is correct (designed value should be 90deg) .
    I have no idea how to measure or calculate the phase difference of two square wave base on synchronizate to acquire these two square wave from two channel on the PCI-6620....
    Anyone can give a idea how to calculate the phase difference with two square wave ?
    Thank a lot and Thanks again...
    Tim

    Tim,
    Here is a simple rising edge detector for one channel.
    Lynn
    Attachments:
    Rising edge.vi ‏15 KB

  • How to calculate the Time difference between 2 dates

    HI All,
    I am using HR_hk_diff_btw_2_dates to calculate the employee service dates.
    For that i  am inputing his hire date and Term dates and Output format as '05' i am getting output perfectly....
    But problem is  whe i am inputting the employee hire date is Dec 1 2007 and Term date is
    March 31 2009 It is coming as 1 year 3 months  31 days instead of 1 year 4 months directly .......How could we make it make last date also working day and get the O/p as 1 year 4 months ?Please Advice..
    Regard
    sas

    1. FM for difference betwwen two times:SCOV_TIME_DIFF
    Import parameters               Value
    IM_DATE1                        2008-01-01
    IM_DATE2                        2008-01-01
    IM_TIME1                        10:00:00
    IM_TIME2                        11:30:00
    Export parameters               Value
    EX_DAYS                         0
    EX_TIME                         01:30:00
    2. SD_CALC_DURATION_FROM_DATETIME : Finds the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE : Finds the time difference between two date/time

  • How to Calculate Sum of Difference between two dates

    Hi,
    I'm using BI Publisher in Siebel CRM.
    In RTF template I have the following expression to calculate the Difference between dates
    <?xdoxslt:date_diff( 'd' , psfn:totext(CIRGSubmittedDate,"yyyy-MM-dd","MM/dd/yyyy"), psfn:totext(Done,"yyyy-MM-dd","MM/dd/yyyy"), $_XDOLOCALE, $_XDOTIMEZONE)?>
    The above expression works for me to calculate the dates.
    I need to calculate the Sum of all these dates for a Group.
    Want to know the Syntax for Sum function using Date_diff.
    Tried the following and didn't work.
    <?Sum(xdoxslt:date_diff( 'd' , psfn:totext(CIRGSubmittedDate,"yyyy-MM-dd","MM/dd/yyyy"), psfn:totext(Done,"yyyy-aMM-dd","MM/dd/yyyy"), $_XDOLOCALE, $_XDOTIMEZONE))?>
    Not sure what I'm doing wrong here...
    Anyone please help...
    Thanks
    PV

    Hi
    To break the diff between 2 dates into days, hours, minutes, sec -- you can use the following:
    select to_char( created, 'dd-mon-yyyy hh24:mi:ss' ),
    trunc( sysdate-created ) "Dy",
    trunc( mod( (sysdate-created)*24, 24 ) ) "Hr",
    trunc( mod( (sysdate-created)*24*60, 60 ) ) "Mi",
    trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Sec",
    to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ),
    sysdate-created "Tdy",
    (sysdate-created)*24 "Thr",
    (sysdate-created)*24*60 "Tmi",
    (sysdate-created)*24*60*60 "Tsec"
    from all_users
    where rownum < 50
    HTH
    RangaReddy

  • How to find the structural difference between two tables

    Hi all,
    How to find the structural difference between two tables .
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thanks,
    P Prakash

    you could try something similar to this, for each table pair that you want to compare:
    SELECT 'TABLE_A has these columns that are not in TABLE_B', DIFF.*
      FROM (
            SELECT  COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_A'
             MINUS
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_B'
          ) DIFF
    UNION
    SELECT 'TABLE_B has these columns that are not in TABLE_A', DIFF.*
      FROM (
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_B'
             MINUS
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_A'
          ) DIFF;that's assuming, column_name, data_type and data_length are all you want to compare on.

  • How to find the phase difference between two signals using Hilbert transform

    hi, 
        I am new to LabView.... I am trying to find phase difference between two signals. I sucessfuly found out the phase difference between two predefined waves using single tone measurement. .... But I really want to know how can I measure phase difference between two signals( not predefined... ie we don't know the initial conditions) using hilbert transform or any transformation techniques (without using zero cross detection).. I tried by using hilbert transform based on algorithm... bt I am getting error.... plz help me
    Attachments:
    phase_differece.vi ‏66 KB

    you could try something similar to this, for each table pair that you want to compare:
    SELECT 'TABLE_A has these columns that are not in TABLE_B', DIFF.*
      FROM (
            SELECT  COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_A'
             MINUS
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_B'
          ) DIFF
    UNION
    SELECT 'TABLE_B has these columns that are not in TABLE_A', DIFF.*
      FROM (
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_B'
             MINUS
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_A'
          ) DIFF;that's assuming, column_name, data_type and data_length are all you want to compare on.

  • How to calculate number of days between two date in Template design?

    Hello guys
    I have a situation where I have to create a template that returns data, and one of the thing of the existing report is that there is a column that is actually the number of days between start date and end date columns..
    So in template, how would I be able to do the same? I have start date and end date columns on the template, now when I created another column using expression like end date - start date and preview the template, I am getting errors saying :
    Caused by: oracle.xdo.parser.v2.XPathException: Cannot convert 03/31/2009 to number.
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
    Please advice
    Thanks

    Hi
    There is an extension function you can use, from the javadoc:
    date_diff
    public static long date_diff(java.lang.String format,
    java.lang.String fromDate,
    java.lang.String toDate,
    java.lang.String locStr,
    java.lang.String tzID)
    Method to get the difference between two dates in the given locale. The dates need to be in "yyyy-MM-dd" format. This function supports only Gregorian calendar.
    Parameters:
    format - the format to which the difference is required; allowed formats are y (for Year), m(for month), w(for week), d(for day), h(for hour), mi(for minute), s(for seconds) and ms(for milliseconds)
    fromDate - the first date
    toDate - the second date
    locStr - locale string -> lang-Territory
    tzID - timezone ID ->http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html
    Returns:
    the difference in dates in the desired format
    For example
    <?xdoxslt:date_diff(‘d’,’2009-09-14’, ‘2009-09-20’,’en-US’,1)?>
    give a result of 6
    You can substitute in columns for the dates, just remember the date format required.
    Regards
    Tim

  • Difference between two date in bex query

    Hi all,
    I need to do a difference between two date using formula variable processing type customer exit beaucause I must use factory calendar in the formula.
    How can I do it?
    Can you give me an example of the routine?
    Thanks a lot
    Gianmarco

    Hi,
    You can still use the same code to copy it and customize as per your need. All you need to do is to subract the dates using the class: CL_ABAP_TSTMP after converting to timestamp and resulting seconds you convert back to days....Please get help from the developers to do this...
    Also, ensure that you write back this difference value to your variable so you get it on the reports for your calculations...
    Cheers,
    Emmanuel.

  • How to get days , months , years between two dates with groovy

    I've a table that contains Start Date and End Date and I want to get the difference between then in this format 2 days , 1 moth , 1year
    Can I make this with Groovy
    I've added a transient attribute to a view object and make its value      return (EndDate) - (StartDate); but this returns the difference of days like 200 day
    I want it in this format 2 days , 1 moth , 1year

    AFAIK - You cannot do it in groovy.
    You can achieve the same using the transient variable approach.
    Create a VORowImpl Class for VO, and in the getter method of the transient variable - do the necessary logic and return the string as required in your use-case.
    Thanks,
    Navaneeth

  • How to set the time difference between each data when sweeping voltage using keithley 2400

    Hello friends,
    I am using the sweep vi from Keithley in the SWEEP and Acquire measurement vi.I want to measure the voltage for every step and insert a delay in between every two data, so I need some delay between each I step.
    I am a starter to use Labview, thanks so much for your answers.
    Perry
    Solved!
    Go to Solution.
    Attachments:
    Keithley 24XX Sweep and Acquire Measurements.vi ‏26 KB

    As Dennis said, if you're using the built-in sweep function, you'll have to check the manual. See Section 10-16 (That's section 10 page 16, not sections 10 though 16) of the Keithley 2400 User Manual.
    The Keithley 24xx series has a measurement speed in units called PLC (Power Line Cycles). The default speed is 1PLC, meaning a measurement is taken every 1 power line cycle, or 1/60th of a second (16.67ms). 24XX's can go from 0.01 PLC (every 0.16ms) to 10 PLC (every 166.6ms). The faster you measure, the lower precision you get.
    To set this value programmatically, the command is
    ENSe:CURRent:NPLCycles <n>
    ENSe:VOLTage:NPLCycles <n>
    depending on what you're sensing and where <n> is the number of PLCs from 0.01 to 10.
    Another factor that will determine the time between data points is the SDM cycle. These are more complicated, look at your Keithley user manual for more information. Look at Section 6 and Section 11 for more info.
    Note:
    PLC times are based on a US cycle of 60Hz.

  • Difference between two dates, using Variables in reporting

    how to calculate the days difference between Delivery date and Billing date in reporting, using variables (SAP BW 3.5v)?

    Hi,
    If you want to do the arethmatioc operations with the date then you will have to declare the date as key figure in the cube and add it there and then update it with the date from R/3.
    You can use formula variable for this subtraction.
    Create a formula in the bex analyzer and then in the down you will get option for the formula varibale.Just make a replacement path varibale on this time characteristic for which yuou want subtraction.
    During creation use "key" in the display and "number" as the data type.
    If number is not working them you can use "date" type.
    Nothing alse needs to be done during the variable creation.
    Once you have made the formula inlcude it in the columns of the report.
    Thanks

  • Difference between two dates

    Hi
    I have two date fields in the ODS..Both are characterists
    1. Requested delivery date
    2. Actual shipment end date.
    I would like to create a calculated KF  field for the difference between two dates in a query.
    How can I accomplish it?
    Regards

    You have to make Expiration data as nav attribute and create a formula variable then only this date can be used in calculations.
    refer this How to...for the same
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/72f4a790-0201-0010-5b89-a42a32223ffc
    later you can try to calculate difference between dates!
    Re: calculating the difference between two dates
    Please search in forum with 'difference between two dates'.You will find lots of good posts on this issue!
    hope this helps
    Regards

  • To find difference between two dates

    Hi all,
    I am new to this forum and oracle.
    I want to get the difference between two dates. My query is as below...
    sqlserver_utilities.datediff('YY', startdate,enddate)
    I want the difference in year.
    Please help me. It's really urgent.
    Thanks in advance.
    Regards,
    Inam

    Select to_char(enddate,'YY') - to_char(startdate,'YY') fromPLEASE don't do that. There are so many things wrong with it...
    for example:
    1). Why are you subtracting character data types?
    2). What if the start date is 1999 and the end date is 2000? Do you expect to get a difference of -1?
    3). What if the start date is 1 Jan 2000 and the end date is 31 Dec 2000? Do you expect to get 0 instead of 1 or .997?
    4). Why would you convert dates to something else when they are inherently subtractable.
    5). There are obvious points in the OP's "specification" that are vague - the best thing (after telling them to search, of course since this has been answered a million times already) would be to try to clarify the spec.
    John

  • Calculate the Difference Between two dates excluding weekends and Holidays

    Hi,
    We need to calculate the difference between the two dates by excluding the Local public holidays (It is global and varies across countries) and weekends should not be included in calculation for a business day in OBIEE.
    We have two dates: Open date and close date when ever close date is null we are calculating age based on taking the current timestamp and need to exclude the weekends and Holidays when ever the close date is null.
    Ex:
    Col1 col2 Total
    11/9/2010 2:46:38 PM Null 13
    11/2/2010 8:06:26 PM 11/3/2010 5:37:03 PM 1
    (In the Total we shouldn't include the weekends,holidays)
    Please let me know how to calculate the difference between two dates by excluding the weekends and holidays.
    Thanks
    Edited by: user10441472 on Nov 22, 2010 3:14 PM

    You already asked this question and I answered it...
    Re: calculation of Business day in OBIEE

Maybe you are looking for