To find the number of years an employee working in an organization

hi,
we need to find how many years an employee working in a particular organization. i.e using the hire date and sysdate we need to find how many years an employee works there. how to execute this.

Hi,
The MONTHS_BETWEEN function returns the number of months between two dates. There's no YEARS_BETWEEN function, but it's very easy to take the value returned by MONTHS_BETWEEN and divide it by the number of months in a year, like this:
SELECT     ename
,     hiredate
,     MONTHS_BETWEEN ( SYSDATE
                 , hiredate
                 ) / 12     AS years_worked
FROM    scott.emp
;Output (when I ran it on June 2, 2013):
ENAME      HIREDATE    YEARS_WORKED
SMITH      17-12-1980         32.46
ALLEN      20-02-1981         32.29
WARD       22-02-1981         32.28
JONES      02-04-1981         32.17
MARTIN     28-09-1981         31.68
BLAKE      01-05-1981         32.09
CLARK      09-06-1981         31.98
SCOTT      19-04-1987         26.12
KING       17-11-1981         31.54
TURNER     08-09-1981         31.74
ADAMS      23-05-1987         26.03
JAMES      03-12-1981         31.50
FORD       03-12-1981         31.50
MILLER     23-01-1982         31.36 
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ {message:id=9360002}

Similar Messages

  • FM to find the number of fiscal weeks in a year

    Hi All,
    Can anyone pls give me the  function module to find the number of fiscal weeks in the given year.
    Thanks,
    Rajani.

    Eric Cartman wrote:
    Ámit Güjärgoüd wrote:
    > > Eric,
    > >
    > > Did you actually enjoy 2004 ?
    wasn't bad...
    do you mean, there were 53 weeks in that year? because I have concern, how it is actually counted...
    wasn't bad... :)
    Thats sounds Sweet
    do you mean, there were 53 weeks in that year?
    Yes
    because I have concern, how it is actually counted...
    If in a leap year fabruary falls in 5 weeks then that is the only possibility for 53 weeks
    Cheers
    PS:But No logic would be applied in this case

  • How to find the number of occurence of a string

    String str="The AR tech seeks experienced candidates in java,jsp. The candidates should have atleast 1 year of experience in the specified skills.";
    here i need to find the number of occurence of the string "experience".
    how to find it out?

    String str="The AR tech seeks experienced candidates in java,jsp. The candidates should have atleast 1 year of experience in the specified skills.";
    String findStr = "experience";
    int count = 0;
    int index = 0;
    while(index != -1) {
    index = str.indexOf(findStr, (count == 0 ? 0 : index + findStr.length()));
    if(index != -1) {
    count++;

  • Trying to find the number of rows in a ResultSet

    I am trying to find the number of rows in a ResultSet, using the following code:
    rs = st.executeQuery(query);
    rs.last(); // to move the cursor to the last row
    System.out.println(rs.getRow());
    However, I am getting this error:
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.last
    Whats going wrong??

    praveen_potru wrote:
    You might have not used scrollable result set..
    Try like this:
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);rs = stmt.executeQuery(sqlString);
    // Point to the last row in resultset.
    rs.last();
    // Get the row position which is also the number of rows in the ResultSet.
    int rowcount = rs.getRow();
    System.out.println("Total rows for the query: "+rowcount);
    cheersAnd I hope the OP would read it because the thread is a year old.

  • BAPI to find the number of records existing in HR module

    Hi ,
    I wanted to know if there exist BAPI  that would return me the number of SAP HR module users in a system.
    I cam across the BAPI's for info types like  personu2019s Personal Data (Infotype 0002)
    BAPI_PERSDATA_CHANGE u2013 Change personal data
    BAPI_PERSDATA_CREATE u2013 Create personal data
    BAPI_PERSDATA_CREATESUCCESSOR u2013 Create subsequent personal data record
    BAPI_PERSDATA_DELETE u2013 Delete personal data
    BAPI_PERSDATA_DELIMIT u2013 Delimit personal data validity period
    BAPI_PERSDATA_GETDETAIL u2013 Read personal data
    BAPI_PERSDATA_GETDETAILEDLIST u2013 read instances with data
    BAPI_PERSDATA_GETLIST u2013 Read instances
    But i wanted to know if there exist a master table which would  return me the number of records irresepctive of the  infotypes.
    Best Regards
    Manoj

    Hi,
    if you want to know the number of employees, then u should  use the infotype PA00001 and PA0000 with appropriate criteria. Infotype PA0002 should not be used to find the number of employees in the HR.
    As you requested there are no specific BAPI to find the records. Hope this helps you.
    Or u can use PAR2 transaction to find details.
    Thanks,
    Saibaba Kondani
    Edited by: Kondani Saibaba on Aug 19, 2009 7:33 AM

  • Finding the number of blocks occupied by a table

    Hi,
    I need to know how much space is being occupied by a table.
    NOTE: I dont need the allocated space of a table. I need the actual space occupied by a table currently.
    I have used the following two methods to determine the size, but i have two contradictory answers..
    The procedure i have used is:
    1. calculate the number of blocks being used.
    2. mulitply the number of blocks by db_block_size to get
    the space occupied by a table.
    I have used two ways to find out the number of blocks, but they both differ.
    Let me know which one is correct or is there any way to find out the number of blocks.
    1st Method
    SQL> analyze table employee estimate statistics;
    Table analyzed.
    SQL> select table_name, blocks, empty_blocks from dba_tables where table_name='EMPLOYEE';
    TABLE_NAME BLOCKS EMPTY_BLOCKS
    EMPLOYEE 184999 5000
    2nd method to find the number of blocks.
    SQL> select count(distinct(substr(dbms_rowid.rowid_to_Restricted(rowid,0),1,8))) from employee;
    COUNT(DISTINCT(SUBSTR(DBMS_ROWID.ROWID_TO_RESTRICTED(ROWID,0),1,8)))
    165058
    From the 1st method i got 184999 as the number of blocks and from 2nd method i got 165058.
    Please help me out as soon as possible.
    Thanks........

    If by "the number of blocks occupied by a table" you mean the number of blocks actually containing data, then the best you can do is an approximation. The supplied package DBMS_SPACE contains a procedure called Unused_Space that will give you the number of blocks above the high water mark. It takes 3 input paramters and returns 7 out parameters. You can call it as:
    DBMS_SPACE.Unused_Space (owner, obj_name, object_type,
                             total_blocks, total_bytes, unused_blocks,
                             unused_bytes, last_used_extent_file_id,
                             last_used_extent_block_id, last_used_block)The output parameters are:
    total_blocks - Number of blocks allocated to the table
    total_bytes - Number of bytes allocated to the table
    unused_blocks - Number of blocks above the high water mark
    unused_bytes - Number of bytes above the high water mark
    last_used_extent_file_id - file id containing the last used block
    last_used_extent_block_id - block id of the last used block
    last_used_block - row slot of the last used block
    Note that this does not take into account any free space within block below the high water mark.
    HTH
    John

  • How to find the number of data items in a file written with ArryToFile function?

    I have written an array of number in 2 column groups to a file using the LabWindows/CVI function ArrayToFile...Now if I want to read the file with FileToArray Function then how do I know the number of items in the file. during the write time I know how many array items to write. but suppose I want the file to read at some later time then How to find the number of items in the file,So that I can read the exact number and present it. Thanks to all
    If you are young work to Learn, not to earn.
    Solved!
    Go to Solution.

    What about:
    OpenFile ( your file );
    cnt = 0;
    while ((br = ReadLine ( ... )) != -2) {
    if (br == -1) {
    // I/O error: handle it!
    break;
    cnt++;
    CloseFile ( ... );
    There are some ways to improve performance of this code, but if you are not reading thousands of lines it's quite fast.
    After this part you can dimension the array to pass to FileToArray... unless you want to read it yourself since you already have it open!
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to find the number of entries in a master data table

    Hi Experts,
    I am trying to find the entries in 0CUSTOMER master data.
    BW>LISTCUBE>Data target: 0CUSTOMER and selected the fields that I need.
    I would like to know how to find the "number of entrees". I tried to run the SUM for a count field, but it is taking forever as there are huge number of records .

    Hi Dev,
    Go to the change/display mode of the info object (0CUSTOMER) in your case. Go to the Master data/Text tab. Here you will find the master data tables according to your settings (P orQ or X or Y). Double click on the table name and it will take you to the SE11 display. From there, you can check the number of records as you do in any transparent table.
    Hope this helps.
    Thanks and Regards
    Subray Hegde

  • How to find the number of links in a website

    hi every body
    can any one clear my doubt
    my doubt is that
    in a website how to find the number of links the hole website contains
    is there any navigation tool to find that
    plz help me yar
    i am waiting for the reply

    If you're talking about commercial sites (sites you don't have the source code for) I'm not sure.
    If you want to count the links in site that you have the source code for, it should be relatively easy to write a Java application to do it. All you really need to do is have a list of the files you want to count links in, read each file line by line and check for the existance of the <a> tag in each line. Anywhere their is an <a> tag there is a link.
    Hope this helps.

  • How to find the number of times method being called.....

    hi,
    can any one pls tell me how to find the number of times the method being called......herez the example....
    Refrence ref = new Refrence();
    for(int i = 0;i < arr.length; i++){
    if(somecondition){
    ref.getMethod();
    here i want to know how many times the getMethod() is calling...Is there any method to do this.. i have seen StrackTraceElement class..but not sure about that....pls tell me the solution....

    can any one pls tell me how to find the number of times the method being called......
    herez the example.... http://www.catb.org/~esr/faqs/smart-questions.html#writewell
    How To Ask Questions The Smart Way
    Eric Steven Raymond
    Rick Moen
    Write in clear, grammatical, correctly-spelled language
    We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding (often enough to bet on, anyway). Answering questions for careless and sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.
    So expressing your question clearly and well is important. If you can't be bothered to do that, we can't be bothered to pay attention. Spend the extra effort to polish your language. It doesn't have to be stiff or formal ? in fact, hacker culture values informal, slangy and humorous language used with precision. But it has to be precise; there has to be some indication that you're thinking and paying attention.
    Spell, punctuate, and capitalize correctly. Don't confuse "its" with "it's", "loose" with "lose", or "discrete" with "discreet". Don't TYPE IN ALL CAPS; this is read as shouting and considered rude. (All-smalls is only slightly less annoying, as it's difficult to read. Alan Cox can get away with it, but you can't.)
    More generally, if you write like a semi-literate b o o b you will very likely be ignored. So don't use instant-messaging shortcuts. Spelling "you" as "u" makes you look like a semi-literate b o o b to save two entire keystrokes.

  • How to find the number of fetched lines from select statement

    Hi Experts,
    Can you tell me how to find the number of fetched lines from select statements..
    and one more thing is can you tell me how to check the written select statement or written statement is correct or not????
    Thanks in advance
    santosh

    Hi,
    Look for the system field SY_TABIX. That will contain the number of records which have been put into an internal table through a select statement.
    For ex:
    data: itab type mara occurs 0 with header line.
    Select * from mara into table itab.
    Write: Sy-tabix.
    This will give you the number of entries that has been selected.
    I am not sure what you mean by the second question. If you can let me know what you need then we might have a solution.
    Hope this helps,
    Sudhi
    Message was edited by:
            Sudhindra Chandrashekar

  • How to find the number of occurance of a string in text field of Infopath form?

    Hi All,
    In Infopath text field, How to find the number of occurrence of a particular string in that field?
    Thanks in advance!

    You can check to see if it contains a string once by using the contains function, but there isn't a very clean way to do what you want. If you wanted to guess at the maximum number of occurrences, then you could:
    Box A has your initial. Set Box B to do a concat of string-before and string-after of Box A where it copies Box A minus the string we're looking for. Then we have Box C that does the same thing to Box B. Repeat as many times as you see necessary.
    Example:
    String: "1"
    Box A - "123451234512345"
    Box B - "23451234512345"
    Box C - "2345234512345"
    Box D - "234523452345"
    etc.
    We then have a field that has nested ifs looking backwards from Z -> A looking for a non-blank. Based on that, we return the number of occurrences. Again, this isn't clean, but it will work if you think there's a predefinable maximum.
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • How to find the number of users  connected to database from OS level(Linux)

    Hi All,
    Could anyone know , how to find the number of users connected to database without connecting with sql*plus
    is there any command to find it?
    example we have 10 databases in one server, how to find the number of users connected to particular database without connecting to database(v$session)?
    oracle version:- 10g,11g
    Operating System:- OEL4/OEL5/AIX/Solaris
    any help will be appreciated.
    Thanks in advance.
    Thank you.
    Regards,
    Rajesh.

    Excellent.
    Tested, works as long as you set the ORACLE_SID first ( to change databases )
    ps -ef | grep $ORACLE_SID | grep "LOCAL=NO" | awk '{print $2}' | wc -l
    Thanks!
    select OSUSER
        from V$SESSION
    where AUDSID = SYS_CONTEXT('userenv','sessionid')
        and rownum=1;Best Regards
    mseberg

  • How to find the number simultaneous call at a given moment on UCCX ?

    Hello,
    I would to know how to find the number simultaneous call at a given moment on UCCX ?
    it's on UCCX or UCCX RTMT, I don't know thanks a lot for your help.
    Aubert

    Hi Gergely,
    I should made a report on the number simultaneous call at a given moment on UCC on the server (all calls on the server)..

  • How to Find the number of Databases in a server.

    HI,
    Please tell me how to find the number of Databases are in a server . when the DB is not up.
    ps -ef | grep ora_
    This i know whether our DB is up or not. But i want to know how many databases are in a server .If the database is down .
    Cheers,
    Gobi.

    Hi,
    [oracle@oralinux admin]$ lsnrctl status
    LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 01-DEC-2006 16:25:41
    Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
    TNS-01169: The listener has not recognized the password
    [oracle@oralinux admin]$
    Plz give me the solution.
    Cheers ,
    Gobi.

Maybe you are looking for

  • Event handling in global class (abap object)

    Hello friends I have 1 problem regarding events in abap object... how to handel an event in global class in se24 . Regards Reema jain. Message was edited by:         Reema Jain

  • Macbook Pro makes a very loud noise as soon as i turn it on

    hi there im having an issue and i was wondering if someone could help me.. basically i only just bought my macbook pro about a week ago and my issue is that every time i turn it on it makes a really LOUD noise which is so irritating! and i know its n

  • How do I get iphoto to recognize my iphone

    My iphone no longer syncs automatically with iPhoto. Has anyone else had this occur and what is the remedy?

  • Crash on wakeup

    I have a Macbook Pro Retina, Mid 2012. As of today my computer crashes and reboots on wakeup.. Anyone else having this problem? Can i fix it?

  • Adobe Reader - kann keine Links in pdf-Datei öffnen

    Hallo Forum, ich habe ein Problem mit Acrobat Reader 9.3.2. Habe ich eine pdf-Datei, wo Links zu Internetseiten bzw. Internetdateien enthalten sind, so kann ich diese nicht aufrufen. Es erscheint immer die Meldung "Sicherheitssperre: Nicht zulässige