How to calculate age of an equipment

Dear guys,
i need to calculate the age of an equipment, i have birth date of it and usuing info provider 0equipment for reporting.
How to subtract birth date from today? do i need to write a formula? i guess there is no sy-datum in bex.
Should i do it in the cube in update rule?
thanks

Hi John,
   You can use any of these function module in routine to calculate the difference between two dates.
1. HR_HK_DIFF_BT_2_DATES
2. PARAMETER:p_date1 TYPE dats,
p_date2 TYPE dats.
DATA:lv_diff TYPE i.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = p_date1
i_datum_von = p_date2
IMPORTING
e_tage = lv_diff
EXCEPTIONS
days_method_not_defined = 1
OTHERS = 2.
IF sy-subrc = 0.
WRITE:/ lv_diff.
ENDIF.[/code]
3. DAYS_BETWEEN_TWO_DATES
4. HR_99S_INTERVAL_BETWEEN_DATES
5. sd_datetime_difference
Check these links:
[https://forums.sdn.sap.com/click.jspa?searchID=13080683&messageID=5146361]
[https://forums.sdn.sap.com/click.jspa?searchID=13080831&messageID=4479989]
    Hope it helps you.
Regards,
Yokesh.

Similar Messages

  • ABAP-HR MODULE(HOW TO CALCULATE AGE & YEARS OF SERVICE)

    HI,
    HOW TO CALCULATE AGE & YEARS OF SERVICE means for example
    I AM USING PNPCE LDB.
    (1) whose age is greater than 52.833 years with 7.833 years of service, with annual rate of pay $170,000 or more, or
    (2) age plus employment service is 65 or more, with annual rate of pay of $ 170,000 or more.
    Note that the $ 170,000 parameter would be a variable that could change annually when this report would be generated. In the past, age and service value were determined as of the run date. The determination date would also be a variable that would change when the report would be generated.
    Thanks&Regards
    Rahul.

    Hi Rahul,
    This is the 2nd warning !!! Please... use the correct or most appropriate forum.
    The ABAP Objects Forum should be used for: ABAP Object definition and implementation including encapsulation, interfaces and inheritance in ABAP Objects.
    This thread will be moved from to .
    You're asking this question in two thread, so the duplicated thread will be deleted.
    Please have a look at [Forum Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] before posting.
    Also read this thread Welcome and Rules of Engagement.
    Greetings,
    Marcelo Ramos

  • How to Calculate AGE by getting difference between two Date Fields

    HI Gems
    I need to calculate AGE from getting difference from two date fields. But when i am trying to wrte fromula as Current date - date1(some date field) then it is showing error.
    How can i get values.
    Thanks
    Manu

    You already asked this question:
    How to calculate AGE from two different date fields

  • How to calculate age in oracle

    Hi,
    T was trying do calculate age as on todays date in ORACLE but after a lot of brain storming i didn't get it.
    Kindly tell me how to calculate age as in years month days.
    For ex.. My DOB- 02-feb-1984 so my age should get as 27 Years 2 months 8 days
    How to do it.
    I tried this
    select
    TRUNC( months_between( sysdate, TO_DATE('02-02-1984','DD-MM-YYYY') )/12 ) Year,
    TRUNC( mod(months_between( sysdate, TO_DATE('02-02-1984','DD-MM-YYYY') ),12) ) Month,
    mod(months_between( sysdate, TO_DATE('02-02-1984','DD-MM-YYYY') ),12) /30 Days
    from dual
    but days are not calculating correctly...
    RGds,
    PC

    sorry..i didn't chck your query..it is right but give wrong answer..
    WITH got_months AS
         SELECT     TO_DATE('02-02-1984','DD-MM-YYYY')
         ,     FLOOR (MONTHS_BETWEEN (SYSDATE, TO_DATE('02-02-1984','DD-MM-YYYY')))     AS months
         FROM     dual
    SELECT     TO_DATE('02-02-1984','DD-MM-YYYY')
    ,     TO_CHAR (FLOOR (months / 12))     || ' years, '     ||
         TO_CHAR (MOD (months, 12))      || ' months, '     ||
         TO_CHAR ( CEIL ( SYSDATE
              - ADD_MONTHS ( TO_DATE('02-02-1984','DD-MM-YYYY')
                        , months
              )               || ' days'
    FROM got_months
    o/p
         TO_DATE('02-02-1984','DD-MM-YY     TO_CHAR(FLOOR(MONTHS/12))||'YE
    1     2/2/1984     27 years, 7 months, 9 days
    1 day more..1     it sud be.. 2/2/1984     27 years, 7 months, 8 days
    if i make correction with add_months like below..
    WITH got_months AS
         SELECT     TO_DATE('02-02-1984','DD-MM-YYYY')
         ,     FLOOR (MONTHS_BETWEEN (SYSDATE, TO_DATE('02-02-1984','DD-MM-YYYY')))     AS months
         FROM     dual
    SELECT     TO_DATE('02-02-1984','DD-MM-YYYY')
    ,     TO_CHAR (FLOOR (months / 12))     || ' years, '     ||
         TO_CHAR (MOD (months, 12))      || ' months, '     ||
         TO_CHAR ( CEIL ( SYSDATE
              - ADD_MONTHS ( TO_DATE('02-02-1984','DD-MM-YYYY')
                        , months
                        )-1
              )               || ' days'
    FROM got_months
    then o/p is..
         TO_DATE('02-02-1984','DD-MM-YY     TO_CHAR(FLOOR(MONTHS/12))||'YE
    1     2/2/1984     27 years, 7 months, 8 days
    correct but cdnt understand why sud -1?

  • How to calculate AGE from two different date fields

    hi
    I need to calculate AGE from two different date fields.
    Can some help me how to do, when i try to do substraction formula it is showing error.
    Thank You
    Manu

    Manu wrote:
    Hi
    Both fields are in date format only, i need to calculate no . of days between two different dates
    Thanks
    ManuThe reason for the question about the format of the column is because the simplest solution only works on DATE columns. Others have mentioned this here, but if you want the difference between two date fields, you can use this formula:
    TIMESTAMPDIFF(SQL_TSI_DAY, date_column1, date_column2)
    The above being said, you still didn't tell me what you did, or what error message you received. So again, if the above formula didn't work, what did you do? Where did you put the formula? What was the exact syntax you used? What was the error message you got?
    Please don't make us work more than we need to. Answer all the questions in your next post. Thanks.

  • How to calculate age in SQL?

    I have a table with DATE as one of the column.
    How do I calculate age?
    Thanks in advance
    -Shilpa

    michaels2 wrote:
    TryWell it still leaves leap year question open. If person was born on February 29, how old is that person on February 28 of a non-leap year? Your code considers it imcomplete year:
    SQL> var dob varchar2(20)
    SQL> exec :dob := '19960229';
    PL/SQL procedure successfully completed.
    SQL> select trunc ( (to_number (to_char (to_date('20090228','yyyymmdd'), 'yyyymmdd'))
      2                  - to_number (to_char(to_date(:dob, 'yyyymmdd'),'yyyymmdd'))
      3                  )
      4                / 10000)
      5            as "Age of Child"
      6    from dual
      7  /
    Age of Child
              12SY.

  • How to calculate Age in BEx query

    Hi,
    I need to calculate age in years based on person's date of birth and the key date that user of the report will enter.
    So, basically in my query I already have date of birth characteristic from 0PERSON InfoObject. I created ZAGE key figure and added it to the query that I would like to populate with person's age.
    So I know I have to enter some code in CMOD for calculated key figure ZAGE to get calculated based on birthdate and key date that user enters. Can somebody help with the code?
    thanks

    Hi,
    The variable should be in "Date" dimension. I have missed one important information in earlier mail.
    The processing type of the variable (user entry date) should be of "Customer Exit' and dimension (in last tab) should be "Date".
    By selecting this dimension, the variable input help screen also appears in calendar format to help user to select date instead of writing it in variable input.
    No need to write any custom code for this variable. We are selecting the "Customer exit" processing type to get Date dimension. In Normal user entry variables we can't get date & time dimension.
    "Ready for Input" should be selected so that user can enter date.
    I hope you can solve your issue now.
    Thanks for your feedback.
    Regards,
    Arun Thangaraj.
    Edited by: Arun  Thangaraj on Oct 8, 2008 8:48 AM

  • How to calculate aging iin query desiner in bi7.0

    Hi all,
    can any help me how to write a formula in bex  QUERY desiner bi7.0
    acullay i have service order creation date in my cube ERDAT and
    business requirements is calculate the aging
    i want to minus the current date with creation date and i need the result in DAYS
    i am new to BI .
    Regards,
    Raja

    Why ask same question again ????
    How to write a formula in BEX in bi7.0
    Create a formula variable of replacement path on service order creation date say ZSCRE
    Create a customer exit variable and populate sy-datum into it in the user exit of CMOD say ZSYDAT
    or
    There is one standard variable available as key date in BEX you can use that too.
    Create a formula or CKF  :
    Age days = ZSYDAT - ZSCRE.
    Hope this helps.
    Edited by: Praveen G on Sep 15, 2008 5:14 AM

  • How to Calculate %age value

    Hi All,
    i have a query
    I have data like below
    cy
    data
    CY 2008
    4290421
    CY 2009
    4069379
    CY 2010
    3979492
    CY 2011
    3940169
    and i want output like this
    cy
    data
    CY 2008
    4290421
    % change
    -5%
    CY 2009
    4069379
    % change
    -2%
    CY 2010
    3979492
    % change
    -1%
    CY 2011
    3940169
    for percent change the formula is in excel for %age change of CY 2008 to CY 2009 = (CY 2009 / CY 2008 -1 )*100
    how we can calculate in SAP BO INFOVIEW 3.1 and it will run automatically in future also for 2012,2013 so on
    Please Advice..
    Thanks in advance.
    Ranjeet

    Hi Riaz,
    Sorry for delay response
    Please find the attachment
    variable (formula) =([data]/Previous([data])-1)*100
    the final result
    if you want more information let me know
    Thanks
    Ranjeet

  • How to calculate age for a business partner for segmentation purposes?

    How do I calculate the age of a BP based on this person's maintained birthday on BP master data?  I need to use this information to segment based on age groups, eg age 30-40, age 25 and below etc.
    I did quite a bit of search on this forum but couldn't find anything.  I know I've seen them somewhere before.  Would appreciate any help and will reward points.  Thanks!

    Hi Jo,
    You can achieve this by using infosets.
    Create Infoset using direct read of table BUT000.
    In infoset select extras for additional field button and give following code for calcualting the difference between Birthdate and system date.
    CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
        EXPORTING
          i_date_from          = but000-BIRTHDT
          I_KEY_DAY_FROM       =
          i_date_to            = sy-datum
            I_KEY_DAY_TO         =
            I_FLG_SEPARATE       = ' '
       IMPORTING
         e_days               = test
            E_MONTHS             =
            E_YEARS              =
    Create a datasource with Business partner GUID and assign it attributelist.
    Choose the additional field for filter criteria.
    Hope it solves your problem.
    Reward points if it helps.
    Regards,
    Madhu

  • How to calculate Age(more details)

    Hi
    I want to calculate the age but not only depending on substracting the years, i have to take into consederation the day and month and year
    for example
    taking into consederation that the date today is 08/08/1999
    someone born on 1/1/1970
    he is 29
    someone born on 18/09/1963
    he is 35
    someone born on 12/12/1976
    he is 22
    how can we calculate the date to get these results
    Thanks

    You can use StringTokenizer to parse out the months, days and years. Once you do that it's easy to compare them to get the age.
    String today = "08/08/1999"
    String bDay = "07/10/1977"
    StringTokenizer st = new StringTokenizer(today,  "/");
    String todayMonth = st.nextToken();
    String todayDay = st.nextToken();
    String todayYear = st.nextToken();Then just do the same thing with bDay and you can compare everything to figure out the age.

  • How to calculate age based on current month and over the next 12 months in Webi 4.1

    Hi,
    I am working on a report where I need to show employees who turned 65 from the time the report is run to over the next 12 months.I have the 'Date of Birth' field available. I am using Bex Query as a data source and webi 4.1. How do I calculate this in Webi 4.1. I appreciate any help.
    Thank you,
    Charvi.

    Hi Charvi,
    Get the all employees who are all in 64 age bucket till yesterday.  Keep indicator for these employees.
    Then obviously these employees will be falling in 65 age in coming 12 months/365 days.
    Same you can get at Bex level also. Create formulae :
    if employee age = 64 then 1 else 0.
    (AGE = 64 * 1 + 0)
    Then create condition on this formulae as Value = 1.
    Revert back your feedback.
    Regards, Vijay

  • How to calculate Age ?

    I have 2 date fields, date1=01-Aug-70, date2=01-Aug-05, when I use the following statement :
    ROUND((date2 - date1) / 365), the result is -64...if seems than system don't know 70=1970 and 05=2005....
    How to solve this problems ?.....
    Thanks, Urgent!

    This PL/SQL function was written by me in 1999 which can be used to select from dual or from any database having a date field:
    create or replace
    FUNCTION date_diff (ddd1 date, ddd2 date) RETURN varchar2 IS
    d1 number(2);
    m1 number(2);
    y1 number(4);
    d2 number(2);
    m2 number(2);
    y2 number(4);
    dd1 date:= ddd1;
    dd2 date:= ddd2;
    feb number(2);
    excep exception;
    begin
    if dd1>dd2 then
    raise excep;
    end if;
    d1:=to_char(dd1,'dd');
    m1:=to_char(dd1,'mm');
    y1:=to_char(dd1,'yyyy');
    d2:=to_char(dd2,'dd');
    m2:=to_char(dd2,'mm');
    y2:=to_char(dd2,'yyyy');
    if substr( to_date('28/02/'||y2,'dd/mm/yyyy')+1,1,2)='29' then
    feb:=29;
    else
    feb:=28;
    end if;
    if d2<d1 then
    if m2 in (2) then
    d2:=d2+31;
    elsif m2 in (3) then
    d2:=d2+feb;
    elsif m2 in (4,6,9,11) then
    d2:=d2+31;
    else
    d2:=d2+30;
    end if;
    m2:=m2-1;
    end if;
    if m2<m1 then
    m2:=m2+12;
    y2:=y2-1;
    end if;
    return
    (lpad(y2-y1,3,' ')||'y '||
    lpad(m2-m1,2,' ')||'m '||
    lpad(d2-d1,2,' ')||'d');
    exception
    when excep then
    return
    ('wrong*dates');
    end;
    A handy code I believe, to relieve you of age-calculation problems
    CHRISTOPHER

  • How to calculate Age of Debt in Days

    Hi experts.
    Basically this is my requirement. I need to produce a column in my query to display the age of debt in days.
    I have inserted Characteristic Value Variable <b>Key Date, 0P_KEYDA</b> in my query. User will give an input to this variable and the report will be produced as at that date.
    Now, there is a column called<b> Age of Debt in Days</b> in my query. The formula is as follow:
    <i><b>Age of Debt in Days = Key Date - Document Date.</b></i>
    I cannot define it earlier during data staging because the Key Date would be dynamic and I wouldn't know the value before the query is executed.
    Can someone let me know on how can that be accomplished?
    Thanks in advance.

    Hi,
    followig is the sample code fro reading value from other variable:
    you can search the forums on how to write a variable exit
    this is the implementation of the cusotmer exit for variable 2:- var2
    METHOD var2.
      DATA: LS_RANGE_IN  TYPE RRS0_S_VAR_RANGE,
        LS_RANGE_OUT       TYPE RRRANGESID,
        L_SCAL_DATE  TYPE D.
    process different steps in the Exit
      CASE I_STEP.
    Exit Call before User Input
        WHEN 1.
    Exit Call after User Input
        WHEN 2.
          READ TABLE I_T_VAR_RANGE WITH KEY VNAM = 'keydate' INTO
                      LS_RANGE_IN.
          VALUE FOR TYPE CUSTOMER EXIT FROM keydate TO var2
          IF SY-SUBRC EQ 0.
            CLEAR:L_SCAL_DATE.
            L_SCAL_DATE = LS_RANGE_IN-LOW.
            CLEAR L_S_RANGE.
              L_S_RANGE-LOW      = L_SCAL_DATE.
              L_S_RANGE-SIGN     = 'I'.
              L_S_RANGE-OPT      = 'EQ'.
              APPEND L_S_RANGE TO E_T_RANGE.
            ENDIF.
    Exit Call to check the variable values at the end
    if raise the exception no_processing the variable screen will appear
    again (see note 492504).
        WHEN 3.
         RAISE no_processing.
      ENDCASE.
    ENDMETHOD  var2.
    in brief:
    processing type 2 : i.e after the variable input
    read i_t_var_range (this structure store all the variable values) where key = keydate(var enterd by user)
    get the date and append it to the current variable.
    you have to write this in Cmod ( it is a bit lengthy procedure, so search in sdn for this)
    hope this helps.

  • How to calculate Age in the RPD level

    I want to create a logical column say 'Age' in the repository. I have the PERS_DOB in the PERSON dimension.
    From this I wrote a query to get the age from the PERSON dimension as below.
    I am wondering if I can create a logical column in the rpd using the sql or is there any way where I can get the age of the persons calculated as a logical layer in the repository.
    select pers_dob, round (((trunc(sysdate)-trunc(pers_dob))/365), 0) from w_pers_d
    Thanks in advance.

    I have created a repository variable 'currentdate' (to get the sysdate) in the rpd and created a new logical column AGE and in the expression builder I used the below and got the syntax error.
    ***round((currentdate-trunc("Program Info b".."Program Info b"."W_PGAD_PR_PERS_D"."PERS_DOB" )/365),0)***
    ***[nQSError: 27002] Near <(>: Syntax error [nQSError: 26012] .***
    I thought functions round, trunc are not supported in OBIEE expression builder and tried the below and got a different syntax error.
    *[nQSError: 27009] Unresolved identifier: "currentdate".*
    Have anyone tried this successfully.
    Please let me know.
    Thanks/

Maybe you are looking for