Calculate age using DOB

Is there a way to calculate age from DOB in the RPD business model layer? In the table, there is only DOB stored in string format (e.g. 19700125, YYYYMMDD format) and we need to dervie age in the RPD.

Here's a hint:
use TimestampDiff funtction
such as TimestampDiff (SQL_TSI_YEAR, date1, now() )
You might have to use CAST function to turn your column into date type....
I hope this is helpful.

Similar Messages

  • To calculate age

    need to create object to calculate age of an employee when he employed using two columns i.e. date of employment and dob, both columns are in different table.
    how to do that?
    let me know if you need more info
    thanks & regards

    Hi,
    1.In Universe _First create the objects with DOE(Date of employeement), DOB(Date of Birth) as a Date object and right click on those objects and set the Object format as Date/Time YYYY. Click on Add for both objects. and Create one more object and select the Object as
    Sum(@Select(Employee/DOE)-@Select(Employee/DOB))
    2. In Web I_ same like above, 2 objects  creation and apply the Fromat in Universe and Web I create a variable with some name as age and in that
    =Sum(DOE-DOB)
    Click ok.
    Hope it will help you...
    All the Best,
    Madhu....

  • Calculate age & auto select result from picklist

    Hi all,
    I understand that you can calculate a person's age using Timestamp but how would I then auto-select the age bracket of the person from a picklist (19-25, 26-40, 41-55, 56+) once the DoB has been selected?
    Thanks in advance,
    T

    create a Repository variable called Current_date and in the init sql
    write
    select trunc(sysdate) from dual
    After this create a logical column Age in BMM and in the column mappings tab of the Logical table source.. in the expression give
    timestampdiff(SQL_TSI_Year,birthdate,VALUEOF('Current_date'))
    Hope it helps..
    Thanks
    Ashish

  • Customer Age with DOB

    Hi,
    In Obiee, I am having customer DOB but i want customer Age as column in BMM layer. How can i get that?

    This seems to handle all the scenarios,
    CASE
    WHEN
    EXTRACT( MONTH FROM BIRTH_DATE) > EXTRACT( MONTH FROM NOW())
    THEN
    TIMESTAMPDIFF( SQL_TSI_YEAR , BIRTH_DATE, CURRENT_DATE ) - 1
    WHEN
    EXTRACT( MONTH FROM BIRTH_DATE) = EXTRACT( MONTH FROM NOW())
    AND EXTRACT( DAY FROM BIRTH_DATE) > EXTRACT( DAY FROM NOW())
    THEN TIMESTAMPDIFF( SQL_TSI_YEAR , BIRTH_DATE, CURRENT_DATE ) - 1
    ELSE TIMESTAMPDIFF( SQL_TSI_YEAR , BIRTH_DATE, CURRENT_DATE )
    END
    For details, http://www.sagelogix.com/sagelogix/knowledge/techtips/SAGEWEB000588
    Also worth reading below postto understand the need for the case statements above,
    Problems calculating age using TimeStampDiff
    Edited by: 855532 on May 25, 2011 2:24 AM

  • 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 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 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 do I calculate age?

    Hi again!
    I would like to calculate a registered users age using the
    date of birth inputted by the user. I want to display this age on
    the profile page of the user.
    Does anyone know of an easy way to do this?

    If dateOfBirth is the variable with their date of birth in
    then as follows:-
    <cfset age = dateDiff("yyyy", dateOfBirth,
    now())>

  • Calculate Age in an ABAP report

    Hi all you wonderful SAP people,
    I am trying to calculate age in my ABAP report,
    Any function module I can use or code snippet? Your help is much appreciated. Points will be awarded.
    Regards
    Ramorua

    Hi Mohamed,  some characters (plus signs, and spaces around the minus) seem to have gotten lost from your code, maybe during the conversion of the forum. Also, the data type is i, not int.
    Header 1
          DATA: lv_age TYPE i.
          lv_age = sy-datum(4) - lv_birthdate(4).
          IF sy-datum+4(4) LT lv_birthdate+4(4).
            lv_age = lv_age - 1. " or SUBTRACT 1 FROM lv_age.
          ENDIF.

  • 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

  • Function Module to calculate age

    Hi Abapers,
    Kindly suggest some function module which can calculate age of a person by taking date of birth till date.
    Thanks in advance,
    Radhika

    Hi Radhika,
    Check this program
    REPORT ZTEST.
    DATA : BIRTH_DATE LIKE SY-DATUM,
           DAYS TYPE NUM2,
           MONTHS TYPE NUM2,
           YEARS TYPE NUM2.
    BIRTH_DATE = '19830307'.
    CALL FUNCTION 'HRCM_TIME_PERIOD_CALCULATE'
      EXPORTING
        BEGDA         = BIRTH_DATE
        ENDDA         = SY-DATUM
      IMPORTING
        NOYRS         = YEARS
        NOMNS         = MONTHS
        NODYS         = DAYS
      EXCEPTIONS
        INVALID_DATES = 1
        OVERFLOW      = 2
        OTHERS        = 3.
    WRITE : / YEARS , 'years' , MONTHS , 'months' , DAYS , 'days'.
    Regards,
    Satish

  • 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

  • Calculate age in oracle 11g

    how do i calculate age based on date picker in another field on the same table/

    Are you sure of that algorithm?
    orclz> SELECT Round((SYSDATE-to_date('01-JAN-1989','dd-MON-yyyy'))/365) FROM DUAL;
    ROUND((SYSDATE-TO_DATE('01-JAN-1989','DD-MON-YYYY'))/365)
                                                           25
    orclz> SELECT Round((SYSDATE-to_date('01-DEC-1989','dd-MON-yyyy'))/365) FROM DUAL;
    ROUND((SYSDATE-TO_DATE('01-DEC-1989','DD-MON-YYYY'))/365)
                                                           24
    How about this:
    orclz> select extract (year from sysdate) - extract( year from to_date('01-DEC-1989','dd-MON-yyyy')) from dual;
    EXTRACT(YEARFROMSYSDATE)-EXTRACT(YEARFROMTO_DATE('01-DEC-1989','DD-MON-YYYY'))
                                                                                24
    orclz> select extract (year from sysdate) - extract( year from to_date('01-JAN-1989','dd-MON-yyyy')) from dual;
    EXTRACT(YEARFROMSYSDATE)-EXTRACT(YEARFROMTO_DATE('01-JAN-1989','DD-MON-YYYY'))
                                                                                24
    orclz>

  • Query to find no of peoples with the same age(using distinct)

    query to find no of peoples with the same age(using distinct)
    Edited by: swordfish3 on Mar 7, 2009 9:24 PM

    it would be helpful if you posted some proper sample data with proper expected results.
    The easier you make it for us to help you, the more likely you will get helped.

Maybe you are looking for