Age in years

Hi there,
I want to select person DOB from a table with the difference between todays date.
or in otherwords, I need to know about person birthdates before one years of their date of birth.
Like if someone born in ((1943 - sysdate)-1) = 59 years
I am doing it like
select
((to_char(sysdate,'yyyy'))-(to_char(p.birth_date,'yyyy'))) Age from person p
But its giving me the wrong results if someone born in 01/01/1943 or someone born in 1st of Jan in any year.
Thanks

Do you want the age of a person minus one year? If so, maybe following will work
select
floor(months_between(sysdate,p.birth_date)/12) age,
floor(months_between(sysdate,p.birth_date)/12)+1 ageplusone,
floor(months_between(sysdate,p.birth_date)/12)-1 ageminusone
from ......
Anna

Similar Messages

  • Cannot find  the age in years csv file  in  the application server

    Hi,
      I want to upload the age in years hierarchy from the CSV  file AGE_E.CSV that should be available in the application server.
      When i try to preview file in the info package, a message is thrown which says that the file does not exist, which means that the perticular file is not present in the application server.
      Can any one of you please tell me where else can i find this file.
    Regards,
    Chetana.

    dear Chetana,
    transaction AL11 can be used to check the file location.
    check DIR_TEMP or DIR_TRANS. or ask basis where the file is put.
    hope this helps.

  • To Calculate age in years

    Hi Experts,
                        I need to calculate the age in years. I have the date of birth already in my infoprovider that  iam using for my query.
    The user will be entering the date on which he want to calculate the age in the selection screen and the date will be stored in a variable..
    Now how to calculate the age in years and display it as a separate coloumn in the report?
    Regards,
    Khan

    Hi,
    Here 1st create the one formula variable on birth date
    then create one more formul variable customer exit varaible with user entry here u cna use the i_step = 2 there user enters which ever that date based on that date it executes
    in CKF: this  customer exit user entry varible - birth date formula varible
    whenever the user enters date based on that now u r getting  days of the employe AGe
    now that CKF can be used in another CKF  by using age/365
    now in report u can keep only second CKF.
    Thanks & Regards,
    Sathish

  • Need age in years based on his/her next birth day.

    Hi,
    I need to Print age in years based on his/her next birth day.
    SELECT TO_CHAR(TRUNC(MONTHS_BETWEEN((SYSDATE ), P.birth_date)/12)) A from employee I used the above code but I get the age with reference to the sysdate only. But what I require is the age based on next birthday.
    For ex: Birth day: 24FEB2000
    Then my expected output is 10.
    If my birthday would have been 24DEC2000, then I would expect a result of '9', please help me with a function or a simple sql statement to code this.
    Thank You

    Maybe something like:
    SQL> SELECT sysdate FROM Dual
      2  /
    SYSDATE
    17-JUN-09
    1 row selected.
    SQL> WITH test_tab AS
      2       (SELECT TO_DATE ('24FEB2000', 'DDMONYYYY') birth_date
      3          FROM DUAL
      4        UNION ALL
      5        SELECT TO_DATE ('24JUL2000', 'DDMONYYYY') birth_date
      6          FROM DUAL
      7        UNION ALL
      8        SELECT TO_DATE ('17JUN2000', 'DDMONYYYY') birth_date
      9          FROM DUAL)
    10  SELECT birth_date,
    11         CASE
    12            WHEN SIGN (  TO_DATE (   TO_CHAR (birth_date, 'DDMON')
    13                                  || TO_CHAR (SYSDATE, 'YYYY'),
    14                                  'DDMONYYYY'
    15                                 )
    16                       - TRUNC (SYSDATE)
    17                      ) <> 0
    18               THEN TRUNC (MONTHS_BETWEEN (TRUNC (SYSDATE), birth_date) / 12)
    19                    + 1
    20            ELSE TRUNC (MONTHS_BETWEEN ((SYSDATE), birth_date) / 12)
    21         END age
    22    FROM test_tab
    23  /
    BIRTH_DAT        AGE
    24-FEB-00         10
    24-JUL-00          9
    17-JUN-00          9
    3 rows selected.
    SQL> Hmm... Sean's Query is better....
    Regards,
    Jo

  • Age in years and length of service wrongly calculated

    I have BI 7.0 implemented by SAP itself , they installed only the business content without any customization
    in HR For The Cube HeadCount 0PAPA_C02  the key figure Age in Years 0AGE_NC is calculating in a wrong way it is subtracting from 1999
    and the field length of service in years 0SRVCLEN_NC is subtracting from 1999 for dates less than 1999 and from 2199 for date more than 1999
    i have searched alot for this but i can't find any solution

    the problem was in the 0CALDAY , it should be set before the calculation
    so i set it to today and everything become fine

  • Why contacts birthdays are being showed in iCloud calendar all with the same age (11 years)??

    Why contacts birthdays are being showed in iCloud calender all with the same age (11 years) ?? There is a solution to solve this problem ??
    Thank-you

    I cannot agree more with your comments! What a way to frustrate your customers!
    I have been having an issue with iCloud on Mac where it kept asking me for my password and sometimes would, sometimes would not continue to access my iCloud mail. Today it just refused to connect to iCloud mail.
    I looked in the Mail, Contacts and Calendars in my MacBook Pro settings and discovered that 2 iCloud accounts were present. One with my original Apple ID (a gmail address) and a second with my new iCloud email ( an @me.com address). Having deleted the second account, using the new @me.com address everything is working fine.
    So from my viewpoint when I moved over to iCloud I was asked to sign in with my Apple ID (the gmail address) then to create an @me.com address. However, as far as I can see all sign ins to the new @me.com account on Macbook, iPhone and iPad need to be done through the old Apple ID (the gmail address). Is that confusing and just plain crazy???
    Further, after creating the new @me.com address I soon found out that this is apparently now forever bound to my old Apple ID and cannot be changed. I mean why can't I delete the iCloud account and start anew with a different @me.com address??? Also, as everybody using iCloud must create an @me.com address why on earth can I not get rid of my old gmail address and have my entire Apple ID accessed through the new @me.com address? Creating a whole new Apple ID will not solve this as we are unable to transfer purchases between accounts.
    Apple products are great IMHO, but they do seem to not think things through in a very big way sometimes......

  • Query to pick up people of retirement age 1 year in advance

    Hi,
    I wrote the below query to pick up all staff who will be of retirement age in a year's time. This will be used in an alert that must go to payroll 1 year before retirement date, then 6 months before retirement date and then finally 1 month before retirement date.
    select distinct papf.employee_number
    , papf.full_name
    , apps.meds_hr_util_pkg.return_department(papf.person_id) org
    , papf.date_of_birth
    , (select payroll_name from pay_all_payrolls_f where payroll_id = paaf.payroll_id) payroll_name
    , (select first_name||' '||last_name from per_all_people_f where person_id = paaf.supervisor_id and trunc(sysdate) between effective_start_date and effective_end_date) mgr
    , (select email_address from per_all_people_f where person_id = paaf.supervisor_id and trunc(sysdate) between effective_start_date and effective_end_date) mgr_email
    , add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') ) ||to_char(sysdate, '-YYYY')),-12) date_12month_advance
    , add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') ) ||to_char(sysdate, '-YYYY')),-6) date_6month_advance
    , add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') ) ||to_char(sysdate, '-YYYY')),-1) date_1month_advance
    , trunc(months_between(add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') ) ||to_char(sysdate, '-YYYY')),-12),papf.date_of_birth)/12) age_12mon
    --into &emp_no, &emp_name, &org, &date_of_birth, &payroll_name, &mgr, &mgr_email, &retirement_date     
    from per_all_people_f papf
    ,per_all_assignments_f paaf
    ,per_person_type_usages_f pptuf
    ,per_person_types ppt
    where papf.person_id = paaf.person_id
    and trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
    and trunc(sysdate) between paaf.effective_start_date and paaf.effective_end_date
    and paaf.primary_flag = 'Y'
    and paaf.assignment_type = 'E'
    and papf.person_id = pptuf.person_id
    and pptuf.person_type_id = ppt.person_type_id
    and trunc(sysdate) between pptuf.effective_start_date and pptuf.effective_end_date
    and ppt.system_person_type = 'EMP'
    and ppt.user_person_type != 'Pensioners'
    and trunc(months_between(add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') )
    ||to_char(sysdate, '-YYYY')),-12),papf.date_of_birth)/12) >= 62
    and trunc(sysdate) in (add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') ) ||to_char(sysdate, '-YYYY')),-12)
    , add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') ) ||to_char(sysdate, '-YYYY')),-6)
    , add_months(to_date(DECODE(to_char(papf.date_of_birth, 'DD-MON'), '29-FEB', '28-FEB', to_char(papf.date_of_birth, 'DD-MON') ) ||to_char(sysdate, '-YYYY')),-1)
    and to_char(papf.date_of_birth, 'DD-MON') != '29-FEB'
    order by 1
    The query works only when I have this line in
    " and to_char(papf.date_of_birth, 'DD-MON') != '29-FEB' "
    As soon as I remove it I get an ORA-01847: day of month must be between 1 and last day of month error. I can't seem to figure out why because there is 1 person with a birth date of 29-FEB and I am catering for this in the query. Also, I am using TO_DATE for the values so using add_months and months_between should not be an issue.
    Please help....maybe someone else can see something I am missing...
    Thanks
    Shalantha

    Hi,
    To find people who are 65 years old (or older) as of today, you can simply say
    WHERE     date_of_birth <= ADD_MONTHS ( SYSDATE
                                       , -12 * 65
                                )ADD_MONTHS knows how to adjust for leap years, but it may not adjust for them the way you expect.
    If today is February 28, 2013, the condition above will include people born on Februry 29, 1948. That's actually 1 day before they reach 65. If that's a problem, the solution is slightly more complicated.
    If today is March 1, 2013, it will include people born on Februry 29, 1948.
    If today is February 29, 2012 (or February 28, 2012) it will include people born on February 28, 1947, but not people born on March 1, 1947.
    To find people who will be 65 years old (or over) 3 months from today:
    WHERE     date_of_birth <= ADD_MONTHS ( SYSDATE
                                       , (-12 * 65) + 3
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data. Simplify the problem as much as possible.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    Edited by: Frank Kulash on May 26, 2011 11:48 AM

  • How to add a new metadata field to iPhoto where new field is calculated as age in years and month based on a specific date and the date photo was taken ? I want to calculate and display the age of my two kids on every photo.

    Hi
    How can I add 2 new metadata-fields to every photo in iPhoto ?
    The new fields should state the age of my kids in years and months based on the date that they were born and the date that photo is taken.
    Exampel:
    My son is born 01.01.2010
    My daughter is born 01.01.2012
    Photo taken by data
    Aage of son
    Aage of daughter
    01.07.2011
    1 year 6 month
    not born yet
    01.01.2014
    4 year 0 month
    2 year 0 month
    I would like to be able to search by kids age and get the info displayed when doing slideshows.
    How to do this in iPhoto ?
    Any alternatives to accomplish the same ?
    Kind regards

    It can't be done with iPhoto.  There are some DAM (digital asset management) applications that can write to other IPTC fields that iPhoto can't read. One such app is Media Pro 1.
    However you would have to calculate the age for each date and add it to one of the fields. There are online age calculators that can do that for you: Age Calculators
    If you go thru that much trouble then use iPhoto, make the calculations and add the age to the Description field.  Then you can use Smart Albums to search for 1year 6 month text.
    OT

  • Query optmization age in year

    Hey there,
    I calculate the year difference between two dates by doing the following thing :
    TRUNC(MONTHS_BETWEEN(RES.SAMPLE_SAMPLING_DATE,RES.PATIENT_BIRTHDATE)/12)+1Do you think that I can optimized this query or do you know any other ways to do the same calculation ?
    Regards,
    Jarod.

    I didn't find my happiness in previous topic forum, mostly, difference between two dates in hours or minutes. Have a look here: https://forums.oracle.com/forums/search.jspa?threadID=&q=age+calculate+leap+years&objID=f75&dateRange=all&userID=&numResults=15
    Actually, I just want to know if you think if my query is sufficiently optimized.It is a common way to calculate age, seen it more than once. You'll have to run tests on your specific configuration to see what could be improved, but I wouldn't spend hours on that.

  • Age Calculation in Years

    I'm rather new to Java, but as a UI designer I've managed to get wrangled into a Java-based project. Anyhow, my mission today is to find the best method of calculating a person's age in years. I will be obtaining the date from a database (using dbSwing), where it is stored in YYYY-MM-DD format as a date.
    I can retrieve the value as a String, Date, or a few other types, but given the particular format of the stored value, I wasn't sure which would be best in passing as a parameter to the end method.
    In summary, I need to take a YYYY-MM-DD date and compare it to the current date to obtain a person's age in years. I note that there are comments concerning 1970 and wasn't sure if any dates before that year would a problem in this calculation.
    I've search about and not really found anything that seems to fit, but again, I'm quite new to the non-UI related parts of Java and any pointers in the right direction would be greatly appreciated. Thanks.

    Heres my stab at it.
    Should be usable with either Date objects or dates in Strings.
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    public class AgeInYears {
         public AgeInYears() {
              try{          
              System.out.println(age("1991-05-17"));
              System.out.println(age("1955-11-01"));
              System.out.println(age("1955-12-01"));
              catch(Exception e){
                   System.out.println("Error " + e.getMessage());
                   e.printStackTrace(System.out);
         public int age(String sDate) throws ParseException{
           SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
           return age(sdf.parse(sDate));
         public int age(Date birthDate){
              // get todays date
              Calendar now = Calendar.getInstance();
              // get a calendar representing their birth date
              Calendar cal = Calendar.getInstance();
              cal.setTime(birthDate);
              // calculate age as the difference in years.
              int age = now.get(Calendar.YEAR) - cal.get(Calendar.YEAR);
              // now for the tricky bit.
              // set the "birth" calendar to be this year
              // this now represents the date of the birthday THIS year.
              // if that date has not occurred yet, subtract one from age
              cal.set(Calendar.YEAR, now.get(Calendar.YEAR));
              if (now.before(cal)){
                   age = age - 1;               
              return age;          
          * @param args
         public static void main(String[] args) {
              new AgeInYears();
    }Cheers,
    evnafets

  • 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

  • Howdo I obtain a column with the calculated age for each member in the membershiplist? memberlist

    The list contains 250 rows of names and their DoB (Date of Birth) = colum A and B.
    The 3r colum should feature the automatically calculated AGE in years only = colum C from TODAY
    It is a **** of a job to input the  DATEDIFF formula for each cell (of colum C).
    Can this be simplified?
    Pleas help to find the right solution for Numbers '09 (version 2.1)
    Thanks

    Hi Lepe,
    Assuming the first row of your table is used for labels (Name, DOB, Age, etc) and the data starts in row 2...
    In C2, enter: =DATEDIF(B2,TODAY(),"Y")
    Hover the mouse pointer over the Fill Handle (small circle) at the bottom right of the selected cell (C2).
    When the mouse pointed turns to a black cross ( + ), click and drag the control down to fill the formula into the rest of the cells in the column.
    For a 250 row table, there are other, more efficient ways of filling the formula down the column. These are described in the User Guide section referenced in Jerry's post.
    Regards,
    Barry

  • Date of Birth in Years - HR Abap

    Hi,
    I need to get the date of birth of the employee in years. Please tell me how to go for it.
    Thanks & Rgds
    Preeti

    TRY DIS CODE...(IFNO FM IS AVAILABLE)
    DATA YEAR(4) TYPE C.
    PARAMETERS DOB TYPE SY-DATUM.
    DATA YEAR1(4) TYPE C.
    DATA AGE.
    YEAR = DOB+0(4).
    YEAR1 = SY-DATUM+0(4).
    AGE = YEAR1 - YEAR.
    WRITE AGE.
    RGDS
    LEMME KNO WHETHER UR PROB IS SOLVED OR NOT.
    Message was edited by:
            abapuser

  • I bought my daughter an ipad mini and used my Apple ID to transfer over her favorites. Now I can't use netflix and hulu. So I want create her an id but it won't let saying too young. I tried to create another one with my age and it still says too young.

    I bought my daughter an ipad mini and used my Apple ID to transfer over her favorites. Now I can't use netflix and hulu. So I want create her an id but it won't let saying too young. I tried to create another one with my age and it still says too young.help!!!

    iTUNES STORE - TERMS AND CONDITIONS
    "This iTunes Service is only available for individuals aged 13 years or older, unless you are under 13 years old and your Apple ID was provided to you as a result of a request by an approved educational institution. If you are 13 or older but under the age of 18, you should review this Agreement with your parent or guardian to make sure that you and your parent or guardian understand it."
    Restart the iPad. Tap Settings > iTunes & App Store then sign in your Apple ID.

  • Age range change preoblem

    SAP deliverd infoobject 0AGE_RANGE with standard age range, but our clients want to have special age range interval and calculate Number of Employees within this range. However HR module doesn't make this kind of range.
    1) How to change the range according to customer's expectation?
    2) How to calculated Number of Employees within this range due to HR team doesn't maintain this age range in R/3?
    3) Should we write ABAP code?
    SAP standard age range
    1  <20
    2  20 - 29
    3  30 - 39
    4  40 - 49
    5  50 - 59
    6  60 - 69
    7  >= 70
    Customer required:
    1     <=25
    2     26 - 30
    3     31 -35
    4     36 - 40
    5     41 - 45
    6     46 - 50
    7     51 - 55
    8     >= 56
    Edited by: hi ni on Apr 19, 2008 5:02 AM

    Hi,
    take a look at 0AGE doc from help.sap.com I think it should solve your problem:
    This characteristic is a derived characteristic. You can use this characteristic to display key figures in accordance with the age of an applicant or an employee.
    The characteristic contains the applicant/employee‘s age at the end of a period. You can define an age hierarchy according to the specific requirements of your enterprise, and then display the age structure of your enterprise, for example. To enable you to perform age-based calculations, the system includes an Age in Years key figure (0AGE_KYF).
    The age characteristics are calculated using update rules at the end of a period. The period depends on the InfoSource from which it is taken. For example, the end of the period can be at the end of a calendar day or month.
    SAP delivers age in years hierarchies in CSV files. (See also InfoSource Age in Years (0AGE)). You can also define hierarchies for the Age in Years characteristic (0AGE). You can determine intervals within the structure as required, for example, in five-year intervals (25 - 29 years, 30 - 34 years, and so on.) Therefore, the age structure that you define yourself offers advantages over the fixed age structure of the Age Range characteristic (0AGE_RANGE).
    http://help.sap.com/saphelp_nw70/helpdata/en/e0/afd837aeadd03ce10000009b38f889/frameset.htm
    Assign points if it was helpful...
    Regards
    Andreas

Maybe you are looking for

  • PDF files in e-tester

    I just taught a new script that looks at and opens a series of PDF files. during the testing everything came up as it should, PDF files opened and displayed. During playback, the external window hangs, and the PDF file(s) never open. I can't find any

  • Reader V8 problem with embedded font

    Hello, I'm having problems opening in Reader V8 the PDF file located at http://www.itech.ca/otf-cff.pdf . The file opens correctly in previous versions of acrobat. AR 4 5 6 7. It complains about the embedded font. Can anyone help me identify the reas

  • Shared Photo Streams Not Updating?

    About a week ago I realized my shared photo streams were not updating. I am not recieving any new photos that my friends are posting, and when I upload new photos they don't go to any of my friends' devices. How can I fix this problem? Thanks!

  • Need help finding my iphone serial number but my phone is dead

    Need help finding my iphone serial number but my phone is dead

  • JPA - How can i add ON DELETE CASCADE constraint ?

    I have a three tables. 1. A (name) 2. B (name) and relationship(manytomany) table of A and B 3. C (a_name,b_name) I am using 2 JPA entities@Entity public class A {      @id      String name;      @ManyToMany      @JoinTable(name="C",                j