Need sql querry for records between Current Year First day and Current Day

Hi,
I have a table like this...
Empid     Empname     DOJ
TEST1     ERDDF     19-Jun-2011
TEST2     AA     22-Mar-2011
TEST3     SS     22-Oct-2011
TEST4     VV     01-Jan-2012
TEST5     HH     01-Apr-2012
TEST6     AS     18-Jun-2012
TEST7     ER     26-Jun-2012
TEST8     ERDDF     28-Jun-2012
My output like this...
Empid     Empname     DOJ
TEST4     VV     01-Jan-2012
TEST5     HH     01-Apr-2012
TEST6     AS     18-Jun-2012
TEST7     ER     26-Jun-2012
Logic:
records between Current Year First day and Current Day(sysdate)

937506 wrote:
Hi,
I have a table like this...
Empid     Empname     DOJ
TEST1     ERDDF     19-Jun-2011
TEST2     AA     22-Mar-2011
TEST3     SS     22-Oct-2011
TEST4     VV     01-Jan-2012
TEST5     HH     01-Apr-2012
TEST6     AS     18-Jun-2012
TEST7     ER     26-Jun-2012
TEST8     ERDDF     28-Jun-2012
My output like this...
Empid     Empname     DOJ
TEST4     VV     01-Jan-2012
TEST5     HH     01-Apr-2012
TEST6     AS     18-Jun-2012
TEST7     ER     26-Jun-2012
Logic:
records between Current Year First day and Current Day(sysdate)Probably you are looking for :
where DOJ between trunc(sysdate,'YYYY') and sysdateRead {message:id=9360002} and always provide details mentioned in this thread.

Similar Messages

  • Need sql querry for  PreviousYear First Day Same Month And Currentday rec

    Hi ,
    I hAVE TABLE FOR EXAMPLE,
    emp sal Arrivaldate
    111 200 03-mar-2011
    100 200 03-mar-2008
    150 200 06-mar-2012
    170 200 03-mar-2003
    178 200 03-mar-2004
    112 200 12-jun-2012-------------------->For Example THIS IS TABLE WE HAVE LOT OF RECORDS
    I need querry to get based on this condition:Arrival Date is between Previous Year First Day Same Month And Current day.
    Any one help me on this.....

    Hi,
    To get the records between Previous Year First Day Same month to Current day..
    SELECT TRUNC (ADD_MONTHS (SYSDATE, -12), 'MM') AS last_yr_first_date, TRUNC(SYSDATE) AS PRESENT_DATE
      FROM DUAL;Which Outputs to:
    LAST_YR_FIRST_DATE     PRESENT_DATE
    6/1/2011                   6/13/2012When you give TRUNC(sysdate) It will removes the Time part of the SYSDATE.
    For Ex :
    TRUNC(SYSDATE) means that is 6/13/2012 which doesn't give the time part in the query.
    Which takes into account the day start that is from 12:00 A.M to today midnight 11.59 P.M.
    And, One thing is that
    emp sal Arrivaldate
    111 200 03-mar-2011
    100 200 03-mar-2008
    150 200 06-mar-2012
    170 200 03-mar-2003
    178 200 03-mar-2004
    112 200 12-jun-2012The arrivaldate is in Character format so you need to convert to date type as
    SELECT TO_DATE(ARRIVALDATE,'DD-MON-YYYY') from your_table;
    and the comparison can be done as
    SELECT *
      FROM YOUR_TABLE
    WHERE TO_DATE (ARRIVALDATE, 'DD-MON-YYYY')
       AND TRUNC (ADD_MONTHS (SYSDATE, -12), 'MM')
       AND TRUNC (SYSDATE);Good day!!!!!!!!!!!!!!!!!!!!!!!!
    Thanks,
    Shankar

  • Need sql querry for this logic

    Hi,
    Edited by: 937506 on Jun 10, 2012 7:35 AM

    937506 wrote:
    Hi,
    I have table like this,based on this table data i need one column for example "Value" based on this condition,
    KEY     A_VAL     ETA_VAL     RANGE     DATE_ID     SITE     AREA     UNIT     Monthnumber     Year
    1111     35     36     50.45     2778     PLANT1     AREA2     CDU-4     8     2011
    1111     40     41     50.45     2783     PLANT1     AREA2     CDU-4     8     2011
    9010     114     37     50.45     2779     PLANT1     AREA2     CDU-3     8     2011
    9010     41     35     50.45     2784     PLANT1     AREA2     CDU-3     8     2011
    9011     1500     38     50.45     2789     PLANT2     AREA3     DHT-1     8     2011
    9012     43     37     50.45     2774     PLANT1     AREA1     DHT-2     8     2011
    9012     38     39     50.45     2781     PLANT1     AREA1     DHT-2     8     2011
    9013     39     40     50.45     2782     PLANT1     AREA2     FCC     8     2011How to ask question
    SQL and PL/SQL FAQ

  • Need sql querry for getting previous day records only

    Hi ,
    i have a table with following records,
    emp sal date
    111 200 03-mar-2011
    100 200 03-mar-2008
    15 200 06-mar-2012
    17 200 03-mar-2003
    178 200 03-mar-2004
    11 200 11-jun-2012
    i need only previous day records only(11 200 11-jun-2012).can any one help on this query?

    insa wrote:
    Except trun you can use Like operator--
    select * from emp where date like sysdate-1;
    Is it helpful for you?That is most certainly not a helpful answer. the LIKE operator is a string comparison operator and should not be used with dates. Doing so will cause an implicit date to character conversion based on the sessions NLS settings and would be not different to doing:
    select * from emp where to_char(date) = to_char(sysdate-1)... which will cause a lack of index usage, and also not deal with any time component within the date.
    Please ensure you test your answers before posting them. Several people had already given correct answers here with explanations as to why they are better than other methods.

  • Need sql querry to retive the data from sysdate to last365 days data.

    Hi ,
    I need sql querry to retrive the data based on this condition:date Between Previous 365 days and current day.
    emp sal date
    1 200 03-mar-2011
    1 200 03-mar-2008
    1 200 06-mar-2012
    1 200 03-mar-2003
    1 200 03-mar-2004
    1 200 03-mar-2005
    and so on.......lot of records....
    i need the all the employee data from currentdate(sysdate) to previous 365 days data...
    Edited by: 937506 on Jun 7, 2012 4:26 AM

    937506 wrote:
    Hi ,
    I need sql querry to retrive the data based on this condition:date Between Previous 365 days and current day.
    emp sal date
    1 200 03-mar-2011
    1 200 03-mar-2008
    1 200 06-mar-2012
    1 200 03-mar-2003
    1 200 03-mar-2004
    1 200 03-mar-2005
    and so on.......lot of records....
    i need the all the employee data from currentdate(sysdate) to previous 365 days data...
    Edited by: 937506 on Jun 7, 2012 4:26 AMJust you can do this
    <date_column> between sysdate-365 and sysdateAnd DATE is a reserved word and you cannot use it as a column name.

  • SQL select Statement -first day and last day of the month - 1 year from now

    Hi,
    I need to write a SQL to get the dates in between first day and last day of the month one year from now.
    SELECT last_day(add_months(sysdate,12)) as lastday from dual
    What could be the Query to get the first day of the month one year from now..
    ie ..Sysdate - 3-DEC-2009
    Result - 1-DEC-2010
    thank you

    Hi,
    You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
    SELECT  TRUNC ( ADD_MONTHS ( SYSDATE
                               , 12
                  , 'MONTH'
                  )     AS first_of_month
    FROM    dual
    ;The DATE returned will be in the same month, year, quearter, ... as the first argument.
    \We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
    At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
    For example, to find all appointment_dates in the current month next year:
    SELECT  *
    FROM    appointments
    WHERE   appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
    AND     appointment_date <  TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
    the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
    the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future.

  • Uploading current year capitalised assets and accum depn

    Dear sir,
    I am working with asset module , I have configured and uploaded legacy assets for previous year capitalised assets. when i came to upload current year capitalised assets , *** and accu depn feild were in display mode and i have uploaded values in takeovers tab  ( accu depn in amount posted--from capitalisation date to 30092010 and *** value in transaction with asset value date as capitalisation date,trn type is 100 and *** values)......
    my configuration is as follows........
    1. Take over date......01012011
    2. last period for depn posted .........2010,09
    3. ord depn start date................01012011 (for all assets)
    but  what my problem is ...................after run the depn for Jan 2011........... accum depn is getting debited and depn is getting credited along with values posted in legacy system also.......... but my client is asking me to post current month depn accordingly............ .
    I am requesting all ,,,,,,,,,, kindly help me on this issue and procedure for  current year capitalised assets and its oasv transactions...........?

    Dear Ajay,
    I am thankfull for your reply ............................. let me tell you the scenario.....
    current year capitalised asset------  apc-50000
                                                              acccum depn till 31dec2010----1666.67(depn per month  416.6666667)
                                                              depn- SLM -USEFUL YEAR-10 (usefull year basis depn)
                                                              capitalisation date---04092010 and
    for above sceanario we should not post depn from capitalisation date to 31 dec2010 because client is already posted depn in non sap system. so If i put ord dep start date as capitalisation date system calculates depn from capitalised date to 31 dec 2010 and posts along  with jan depn -
    but it is enirely wrong for this scenario. according to our scenario we can post depn for the month of jan in sap .......
    I hope now you clear about scenario,,,,,
    Regards,
    ummi.

  • Report for current day and current month

    Hi gurus,
    i 've a report, where i 've to display the values for qty and cost of the material for the current day and current month
    HOw can i do this in BEx Query designer..If any document plz share
    thanks
    rakesh

    hi Kolli
    here i want to filter the data on system date,
    i wnt the report to pick the date dynamically based on the system date.
    but i think restricting on calmonth and calday is not going to solve my scenario..
    rakesh

  • My iPhone 5 ,iOS 7.0.2 after rstore firmware ,now need old email for activation , but i dont know email and password , what can i do?

    my iPhone 5 ,iOS 7.0.2 after rstore firmware ,now need old email for activation , but i dont know email and password , what can i do?

    Hi mt.ahsan!
    I have a website for you that can help you find that Apple ID, then you can reset the password for it if necessary:
    Apple ID: How to find your Apple ID
    http://support.apple.com/kb/HT5625
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Goodnight buy "CREATIVE CLOUD - INDIVIDUALS - FULL" annual plan prepaid debit my credit card for 599.88 dlls year, already authorize and charge the amount the card twice and I never get the confirmation of the purchase by you (ADOBE) as if he had not boug

    Goodnight buy "CREATIVE CLOUD - INDIVIDUALS - FULL" annual plan prepaid debit my credit card for 599.88 dlls year, already authorize and charge the amount the card twice and I never get the confirmation of the purchase by you (ADOBE) as if he had not bought anything despite what the charge generated in TWO OCCASIONS.
    As one refund request and the remaining as active, THANK YOU for your attention.

    Adobe contact information - http://helpx.adobe.com/contact.html may help
    -http://helpx.adobe.com/adobe-connect/adobe-connect-phone-numbers.html
    -orders, returns http://helpx.adobe.com/x-productkb/global/phone-support-orders.html
    -says 800-443-8158 for payment problem in https://forums.adobe.com/thread/1551495

  • Does anyone have a suggestion for an app for recording phone calls that is reliable and easy to use?

    does anyone have a suggestion for recording iphone4s calls that is reliable and easy to use

    There are no such apps that work. Doing so would require routing the call through a 3rd party service.

  • I had free adobe reader and i scanned a doc to send to a client and as of last night i could not send as an attachment thru my email. So I paid for the 89.99 year adobe pkg and it still wont let me email a scanned and saved doc. it says 'an unknown error

    i had free adobe reader and i scanned a doc to send to a client and as of last night i could not send as an attachment thru my email. So I paid for the 89.99 year adobe pkg and it still wont let me email a scanned and saved doc. it says 'an unknown error occurred'?

    What exactly means "could not"?
    And what Adobe product/service did you pay for?

  • For the previous month first day and last day

    i want to schedule my reports from the last month first date to last month last date.
    any body have queries for the while scheduling to uuse it.
    Ex:sysdate() - today's date
    first_day_of_month()- first day of current month
    first day of last month ---?
    last day of the last month ---?

    In the parameter, put this
    {$FIRST_DAY_OF_MONTH()$}other values you can use in default parameter values are
    {$SYSDATE()$} - to get current date
    {$FIRST_DAY_OF_MONTH()$} - to get first day of the current month
    {$FIRST_DAY_OF_YEAR()$} - to get first day of the current year
    {$LAST_DAY_OF_MONTH()$} - to get last day of the current month
    {$LAST_DAY_OF_YEAR()$} - to get last day of the current year
    Re: Default date as first of month
    TO get last day of last month
    {$FIRST_DAY_OF_MONTH()-1$}You can add/subtract number with these functions and no other functions are available.

  • Need SQL code for this logic - -  From Serial and To serial no.

    In Forms 4.5 Screen I have two text boxes where i will be entering From Serial No
    and to serial no.
    I want the code which will check whether any number in between these from and to serial exists in a table or not ?
    For Example
    Select * from t; -- contains
    serial number
    321-456-789
    123-456-654
    321-569-986
    321-569-987
    When I enter from Serial no 321-456-789 and to serial no as 321-456-789.. I should get a message sayinig that 321-456-789 exists.
    When I enter from Serial no 321-569-986 and to serial no as 321-569-988.
    I should get a message sayinig that 321-456-986 exists.
    I should get a message sayinig that 321-456-987 exists.
    I should get a message sayinig that 321-456-988 not exists.
    is it possible with a SQL query or do we need to go for procedure or temp table ?
    If anybody ahving similar code please post it here.
    Thanks in Advance
    Devender

    Hi Devender,
    Try this :
    SQL> select * from t;
    SN
    321-456-789
    123-456-654
    321-569-986
    321-569-987
    SQL> var sn1 varchar2(11)
    SQL> exec :sn1 := '321-569-986'
    Procédure PL/SQL terminée avec succès.
    SQL> var sn2 varchar2(11)
    SQL> exec :sn2 := '321-569-988'
    Procédure PL/SQL terminée avec succès.
    SQL>1  select a.sn, decode(t.sn,null,'does not exists','already exists')
      2  from
      3  (select substr(replace(:sn1,'-','')+rownum-1,1,3)||'-'
      4        ||substr(replace(:sn1,'-','')+rownum-1,4,3)||'-'
      5        ||substr(replace(:sn1,'-','')+rownum-1,7,3) as sn
      6  from (select level
      7        from dual
      8        connect by level <= (replace(:sn2,'-','')-replace(:sn1,'-',''))+1
      9       )
    10  )a,
    11  t
    12* where a.sn=t.sn(+)
    SQL> /
    SN                            DECODE(T.SN,NUL
    321-569-986                   already exists
    321-569-987                   already exists
    321-569-988                   does not exists
    SQL> exec :sn1 := '321-456-789'
    Procédure PL/SQL terminée avec succès.
    SQL> exec :sn2 := '321-456-789'
    Procédure PL/SQL terminée avec succès.
    SQL> l
      1  select a.sn, decode(t.sn,null,'does not exists','already exists')
      2  from
      3  (select substr(replace(:sn1,'-','')+rownum-1,1,3)||'-'
      4        ||substr(replace(:sn1,'-','')+rownum-1,4,3)||'-'
      5        ||substr(replace(:sn1,'-','')+rownum-1,7,3) as sn
      6  from (select level
      7        from dual
      8        connect by level <= (replace(:sn2,'-','')-replace(:sn1,'-',''))+1
      9       )
    10  )a,
    11  t
    12* where a.sn=t.sn(+)
    SQL> /
    SN                            DECODE(T.SN,NUL
    321-456-789                   already exists
    SQL> Nicolas.

  • Need sql query for typical scenario

    Hello Champs,
    I have a scenario where I am suppose to fetch data from a schema which is developed by other team ... (there are no primary keys even)
    the table structure is -
    Column A Column B Column C Column D
    1 h 6 u
    1 h 7 u
    1 h 8 u
    2 g 9 i
    2 g 0 i
    2 g 7 i
    3 t 3 h
    3 t 4 h
    3 t 5 i
    and my output should be exactly like :
    1 h 6,7,8 u
    2 g 9,0,7 i
    3 t 3,4 h
    so basically I want comma separated values for column c where remaining column values are same ...
    is it possible to achieve this result via SQL?? if not then what is the other solution??
    Please help .. I am working in IST and need solution urgently for this .. please help .
    TIA,
    Regards,
    Chintan

    if you have 11g
    WITH t AS (SELECT 1 cola,
                      'h' colb,
                      6 colc,
                      'u' cold
                 FROM DUAL
               UNION
               SELECT 1,
                      'h',
                      7,
                      'u'
                 FROM DUAL
               UNION
               SELECT 1,
                      'h',
                      8,
                      'u'
                 FROM DUAL
               UNION
               SELECT 2,
                      'g',
                      9,
                      'i'
                 FROM DUAL
               UNION
               SELECT 2,
                      'g',
                      0,
                      'i'
                 FROM DUAL
               UNION
               SELECT 2,
                      'g',
                      7,
                      'i'
                 FROM DUAL
               UNION
               SELECT 3,
                      't',
                      3,
                      'h'
                 FROM DUAL
               UNION
               SELECT 3,
                      't',
                      4,
                      'h'
                 FROM DUAL
               UNION
               SELECT 3,
                      't',
                      5,
                      'i'
                 FROM DUAL)
      SELECT cola, colb,  listagg (colc, ',') WITHIN GROUP (ORDER BY colc) colc, cold
        FROM t
    GROUP BY cola, colb, cold
    COLA     COLB     COLC     COLD
    1     h     6,7,8     u
    2     g     0,7,9     i
    3     t     3,4     h
    3     t     5     i

Maybe you are looking for

  • What's the best map in india for BlackBerry user?

    I am new to BlackBerry world..in india bb map is not available....so am having difficulty in navigation without any app!!and also tried google map..but they are useless without google play...!so kindly help me in this!!!!

  • Cannot start Backup of Azure VM Windows Server

    Whenever I start a backup of an Azure VM, I get the following error message: Snapshot VM sub task timed out. Please retry the operation in a few minutes. If the problem persists, contact Microsoft Support. I contacted Microsoft Support, but they told

  • My websites and UI have suddenly become huge. How can I get them back to a normal, smaller size?

    Yesterday all of a sudden my webpages and UI appeared to be magnified. While I can zoom out on websites, I cannot find any option to adjust the size of the UI. I noticed that Firefox 22 (which I am running) has a new feature: "Windows: Firefox now fo

  • Job cancel

    Hi, While cancelling the process in SM66, how to find out the corresponding job in SM37 to make sure that we are cancelling the right job? Thanks.

  • System("read") command

    Hello. I've got the following code in a program: printf("%s", "the text that I want to print to the console"); system("read"); The purpose here is to have the text from the printf( ) statement above print to the console, and then have the program pau