Calculate the age of a person from today

I'm writing a query where I'm trying to figure out how old a person is starting today.

So, I have a database field in my STUDENT_TB (table) where the birth_date is a DATE field. I'm writing a query where I would like to calculate the age of the person.

So, if a person is 48 years old and 6 months 2 days, I would essentially say the person is 48 years old. Any help is greatly appreciated.

I tried using MONTHS_BETWEEN but run into some problems. I tried using P_END_DATE - P_START_DATE and then he dive by 365, but which is at the origin of the problems too.

Thank you!

Roxyrollers wrote:
I'm writing a query where I'm trying to figure out how old a person is starting today.

So, I have a database field in my STUDENT_TB (table) where the birth_date is a DATE field. I'm writing a query where I would like to calculate the age of the person.

So, if a person is 48 years old and 6 months 2 days, I would essentially say the person is 48 years old. Any help is greatly appreciated.

I tried using MONTHS_BETWEEN but run into some problems. I tried using P_END_DATE - P_START_DATE and then he dive by 365, but which is at the origin of the problems too.

Thank you!

What exactly are the problems you are having?

select
   floor(months_between(sysdate, to_date('01-jan-1978','dd-mon-yyyy')) / 12) as years_old
from dual;

 YEARS_OLD
----------
     32

1 row selected.

TUBBY_TUBBZ?

Tags: Database

Similar Questions

  • Query to calculate the age

    Hello

    Please suggest me to wirte a function that can calculate the age.

    Hello

    No need for a function. But a simple calculation.

    SQL> select round(months_between(sysdate,to_date('11-MAY-1977','dd-MON-YY'))/12) age from dual;
    
           AGE
    ----------
            33
    

    If you take into account the dates stored in an oracle table column can take care of the years
    before and after 1950.
    A thread for your reference: Re: day airthmetic

  • How can I move the hair of a person from one photo to another and place it on another person?

    How can I move the hair of a person from one photo to another and place it on another person? I went through each instructional video you have and have not been able to master this. I tried the smart brush without result, and frankly, I don't think that your product is very intuitive. I work with the software as a professional and I would like to speak directly to someone who could guide me through this process, as I do for one of my clients of having problems with the software that I represent. Thanks, my email is [email removed by host address]

    First of all , we do not communicate with posters by private email.

    The purpose of the forum is for everyone to benefit from the questions and answers, not only the original poster.

    Secondly, you do not discuss Adobe here in the user forums.  You ask the help of users of volunteers like you who give their time for free. Nobody has any obligation to answer your questions.

    Thirdly, Adobe does not support tutoring hand-holding, step by step that you are looking for.  They have excellent video tutorials on Adobe TV.

    Photoshop is a professional application, making no apologies for his very long and steep learning curve

    Read this FAQ to get advice on how to ask your questions correctly to get faster and better answers:

    http://forums.Adobe.com/thread/419981?TSTART=0

    Finally, the titles of topic or subject should be clear, relevant and concise so that individual users can tell at a glance if they can help or not.

    This field is not for trying to adjust your entire question in there.

    Keep this in mind next time you post.  Thank you.

    Thank you!

    EDIT/ADDENDUM: on the other hand, if your ID Adobe is indicative of your true identity, like the beautiful Jay López, in real life, I and others here will be happy to oblige with one-on-one tutoring.

  • I have problems with D4.1 in Labview ' 09. It is said to determine the age of a person in years, when given the month in course, day, and year and month of birth of the person, day, and year

    Seen someone's birth month day and year... and also the day of the current month and year like entries... calculate their age, years... as output... age should not increment by one until the arrival of their birthday this year.   I can't get the coding right... Please help


  • Calculate the (age) years between two dates

    Nice day!

    I have not been able to find an answer, that I was able to use in the archives or online and would be very grateful for the help.  I'm working with Adobe Acrobat Pro XI (not LiveCycle) and I have very little experience with programming (for the most part, copy / paste).

    I need to create a text box that calculates the number of years between two dates entered, i.e. the age when the date of birth and death are given.  Also, would be nice if she was a Virgin until the two were provided.  Anyone would be able to give me the code I need to put in the custom calculation script?

    Once again, any help would be much appreciated!  Thank you and have a wonderful day!

    For the fields for Date of birth DOB and DOD for the Date of death and age in complete years both by using a'd-mmm-yyyy' date format you can use a custom calculation to the JavaScript for the field of age as:

    function GetField (cName) {}
    get the field with error trapping object;
    oField var = this.getField (cName);
    test error;
    if(oField == null) app.alert ("error during the" + cName, 1, 0);
    Returns the field object;
    return oField;
    } / / end GetField function;

    function {Scand (cFormat, cString)
    using date string format convert object date;
    convert string to date using format;
    Kai var = util.scand (cFormat, cString);
    the value null is an error of conversion;
    if(oDate == null) app.alert ("Conversion error" cString "by using the format" + cFormat, 1, 0);
    date of return;
    Return to oDate;
    } / / end Scand function;

    clear the value of the field;

    Event.Value ="";
    get data dob and dod;
    var oDOB = GetField ("DOB");
    Var o = GetField ("DOD");

    treat only if DOB and DOD have value and are not null;
    If (oDOB! = null & o! = null & oDOB.value! = "" & oDOD.value!) = "") {}

    convert the DOB and DOD to date objects.
    oDOB var = util.scand ("d-mmm-yyyy", oDOB.value);
    O var = util.scand ("d-mmm-yyyy", oDOD.value);

    get the difference over the years;
    var Age = oDOD.getFullYear () - oDOB.getFullYear ();

    adjust for month of previous DOD DOB;
    If (oDOD.GetMonth)< odob.getmonth())="">

    adjust the DOD before DOB date in the month of birth;

    If (oDOD.GetMonth () == oDOB.getMonth () & oDOD.getDate ())< odob.getdate())="">
    Set the value of the field;

    Event.Value = Age;
    }

  • How to calculate the age?

    Hi again!

    I would like to calculate an age registered users using the date of birth entered by the user. I want to show that age on the profile of the user.

    Does anyone know an easy way to do this?

    If dateOfBirth variable with their date of birth then is as follows: -.

  • Calculate the age (months and years) of two dates

    Trying to get the (almost exact) age in years and months to fill in 'Age at the time of retirement' (years1) since the date of birth (DOB1) and the date of their departure in retirement (retireDate1). The only examples that I could find are dates "today." If anyone can help with code? And I understand it works better with JavaScript but FormCalc would also work?

    Dates as DD/MM/YYYY

    Field is num {z9}

    Thank you in advance for your help!

    I could do this work with Age1 as a text field. Of course, you can do whatever you want with it, but this method makes the most sense for me because I can say 99 months "99 years". If you need to separate the year and month in different areas, you should be able to do it easily. Finally, it requires that the user does not manually enter dates. (Something on the raw values isn't quite right when they came from the selection.)

    Age1::calculate (or anywhere where you want this event)

    if (!DOB1.isNull && !retireDate1.isNull){
      var d1 = DOB1.rawValue.split('-');
      var d2 = retireDate1.rawValue.split('-');
      var years = parseInt(d2[0]) - parseInt(d1[0]);
      var months = (parseInt(d2[1]) - parseInt(d1[1]));
      if (parseInt(months) < 0){
        months = 12 + months;
        years--;
      }
      Age1.rawValue = years + " years " + months + " months.";
    }
    
  • How can I use a date in the format YYYYMMDD "" to calculate an age?

    I do a form and I want to use a military format "YYYYMMDD" date to calculate the age of the user. I found the code to find the age based on a date in the format "yyyy/mm/dd", but I have trouble finding the age after adding slashes with javascript after the date input. I use Adobe Acrobat Pro DC on OSX 10.11.6. Thanks in advance.

    Replace these two lines:

    var cDob is getField (cBirthDate) .value;.

    var cCutoff is getField (cCutoffDate) .value;.

    With this:

    var cDob is getField (cBirthDate) .valueAsString;.

    var cCutoff is getField (cCutoffDate) .valueAsString;.

  • Using two dates to find the age...

    Hello

    I need to find the age of a person the DOB entered into service.  the age may be days or years depending on when the person was born.

    If the person was born is less than a year, so I should be able to calculate the number of days on the other, it should be over the years.

    I can't find the right way to do it.  I tried like this but its does not work as it should:

    todaysDate long = (new Date()) .getTime ();
    long date of birth = dobDateField.getDate ();

    long dateDiff = todaysDate - date of birth;

    multiply a day with 365 days (ignore the leap year for now)
    length of year = DateTimeUtilities.ONEDAY * 365;

    If (dateDiff< year)="">
    int NoOfDays = (int) (dateDiff / DateTimeUtilities.ONEDAY);
    ageEditField.setText (String.valueOf (NoOfDays) + "D");
     
    } else {}
    int NoOfYears = (int) (dateDiff/year);
    ageEditField.setText (String.valueOf (NoOfYears));
    }

    Help, please...

    int age = (diff / (1000 * 60 * 60 * 24));
    int years = 0;
    
    if( age >= 365 ) {
       years = age / 365;
    }
    
    if( years > 0 ) {
     // use years
    } else {
     // use days
    }
    

    Something like that.

  • The age factor

    Guyz,

    I have a text field on my module called DOB (Date of birth) and a disply Age column. How to calculate and display the age in my area of age.

    have me/JJ/AAAA format of data when the user enters the data in DOB on key-next-item trigger, it will calculate the age and treats the next field.

    How can I calculate this age?

    Concerning

    Houda

    something like this:

    select trunc( ( sysdate - :DOB ) / 365 ) from dual
    

    or

    :AGE :=  trunc( ( sysdate - :DOB ) / 365 ) ;
    
  • Query for the age calculation problem

    Hello

    I am trying to calculate the age using MONTHS_BETWEEN, then divide by 12

    CREATE TABLE DOB (date of DATE_OF_BIRTH);

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('13-JAN-54','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('26-APR-54','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('30-JUN-29','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('03-JAN-67','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('04-AUG-49','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('27-DEC-47','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('21-MAR-67','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('26-SEP-56','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('06-MAY-52','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('01-JAN-00','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('07-JUL-63','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('24-JAN-62','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('22-OCT-63','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('15-OCT-36','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('06-SEP-36','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('27-FEB-60','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('03-NOV-75','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('08-APR-52','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('21-APR-60','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('22-MAR-57','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('21-SEP-63','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('27-JAN-73','DD-MON-RR'));

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('29-SEP-65','DD-MON-RR'));

    Select trunc (MONTHS_BETWEEN (SYSDATE, DOB. (DATE_OF_BIRTH) / 12) AS the "âge" of DOB.

    Output

    Age

    ---

    59

    59

    -15

    46

    -35

    -34

    46

    56

    61

    13

    50

    51

    49

    -23

    -22

    53

    37

    61

    53

    56

    49

    40

    47

    I get some as negative age and others as positive tried using "MON-DD-YY" but same result.

    any suggestion

    Thanks for your help.

    Hello

    The formula you use is a good way to get the age in years.
    The problem is that some of your "date of birth" are in the future.  For example:

    Insert into values of birth date (DATE_OF_BIRTH) (to_date('30-JUN-29','DD-MON-RR'));

    We hear June 30, 2029, a little less than 16 years into the future.  When you truncate this number, you get-15...

    In RR version, the actual year is between 2000 and 2049, years-00 to 49 years old are considered as in the current century, but 2000 to 2049.

    This is an example of why you should always use figures 4 years and "YYYY" format, like this:

    Insert into (DATE_OF_BIRTH) date of birth values (to_date (June 30, 1929 ', "DD-MON-YYYY"));

  • Between the prompt on the age

    Gurus and Experts,

    I invited on the age of the column between edit box.
    I calculate the age as BOX WHEN "BOB Datamart. » ». "" "" BOBDBO '. "" "" "Dim_INVOLVED_PARTY_DIM_Client '." " BIRTH_DT' = TIMESTAMP ' 01/01/01 00:00:00 ' AND THEN ANOTHER NULL (TIMESTAMPDIFF (SQL_TSI_DAY, TIMESTAMP ' 1900-01-01 12:00 ', VALUEOF (NQ_SESSION.)) (("" CURRENT_DT ")) * 86400000 - TIMESTAMPDIFF (SQL_TSI_DAY, TIMESTAMP ' 1900-01-01 12:00", "BOB Datamart" "." ") ». "" "" BOBDBO '. "" "" "Dim_INVOLVED_PARTY_DIM_Client '." " (BIRTH_DT") * 86400000) / (365.25 * 86400000) END
    The age is displayed up to 2 decimal places. The problem is that if a user is prompting the same values in the ex 30.25 30.25 editing area, the results not obtaining appears when there with age 30.25.

    THX.

    then you can try with this formula right?

    --

     TmestampAdd(SQL_TSI_YEAR, DateOfBirth, CURRENT_DATE) 
    

    --

    Sorry... should be: timestampDiff

     TmestampDiff(SQL_TSI_YEAR, DateOfBirth, CURRENT_DATE) 
    

    Published by: Kishore Guggilla, October 19, 2010 18:19

  • From today, many words I type, for example "of" "and" and "type" AutoCorrect for the word "nyoom". How can I fix?

    From today, many words I type, for example "of" "and" and "type" AutoCorrect for the word "nyoom". What nyoom? I'm not how to turn off auto correct, I know how to do this. I'm trying to understand what happened to my iPad, and I would like to address them.

    iPad 2 Air

    iOS version 9.3.1

    I think someone pulled a prank on you.

    https://www.Buzzfeed.com/expresident/nyoom-nyoom-nyoom?

    Check the automatic correction feature!

  • I use Adobe Photoshop on a daily basis, from today, that the program has disappeared from my computer. Is it possible to restore the program or to understand what happened?

    I use Adobe Photoshop on a daily basis, from today, that the program has disappeared from my computer. Is it possible to restore the program or to understand what has happened through Windows XP Pro?

    Has it really been uninstalled... or if only the shortcut has disappeared?

    Click Start > search, select "All files and folders", then search for photoshop.exe

    I do not have Photoshop installed, but if it's like other Adobe applications, he located in C:\Program Adobe Photoshop.

  • Load profile with the temporary account from today

    original title: temporary user profile problem! Desperately need help!

    I have windows vista. All user profiles are loading with temporary account from today. I lost all my data. Help, please. Usually when I restart my computer, the profiles are back to normal. But not now? Help, please

    Hello

    1st thing to try is the system in safe mode restore to before the problem

    http://www.windowsvistauserguide.com/system_restore.htm

    Windows Vista

    Using the F8 method:

    1. Restart your computer.
    2. When the computer starts, you will see your computer hardware are listed. When you see this information begins to tap theF8 key repeatedly until you are presented with theBoot Options Advanced Windows Vista.
    3. Select the Safe Mode option with the arrow keys.
    4. Then press enter on your keyboard to start mode without failure of Vista.
    5. To start Windows, you'll be a typical logon screen. Connect to your computer and Vista goes into safe mode.
    6. Do whatever tasks you need and when you are done, reboot to return to normal mode.

    If that does not solve it read more

    Your user profile was not loaded correctly! You have been logged on with a temporary profile.

    http://support.Microsoft.com/kb/947242

    If you tried to log on to Windows and received an error message telling you that your user profile is damaged, you can try to fix it. You will need to create a new profile and then copy the files from the existing to the new profile. You must have at least three user accounts on the computer to perform these operations, including the new account that you created.

    http://Windows.Microsoft.com/en-us/Windows-Vista/fix-a-corrupted-user-profile

Maybe you are looking for

  • "cable fraying problem" faced by many users of MacBook?

    Mr President, what is the efficient solution for "cable fraying problem" faced by many users of MacBook?

  • Why pdf files not open in firefox and display on the screen?

    I'm unable to view pdf files in firefox and do Explorer as default. Why is this happening?

  • Satellite L650 - 1 MM-video display problem

    Greetings from Finland. So, about a month I bought this laptop of mine, Satellite L650 - 1 MM, and I was wondering what the heck is the problem with the video display. Don't know about you is this a problem with the hardware or just something with th

  • portable printer HP officejet 100

    Portable printer HP Officejet 100 has all the flashing lights on his Panel.  And I can't print.  Cannot close the printer is down. Troubleshooting and received the message that no problems detected. Any suggestions?

  • error: cannot update the 80070490

    I can't get updates because of the error code. I also have problems with certain emails. Thus, this file does not have a program associated with it for performing this action. Create an association in the set associations Control Panel. Don't know ho