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

Similar Messages

  • 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 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.

  • 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 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.

  • Usage warning for first day of month

    Oh dear, I get the following warning for the first day of the month.
    "You are within your June usage allowance but are likely to go over before the end of the month."
    This after  0.45Gb use the first day.
    My normal usage for nearly 2 years has been around 1.5Gb a month, except for May when I used 2.47Gb most of which was in the last 3 days of the month,  the reason why.... I bought a new computer and with all the updates it down loaded it pushed the usage up, hopefully now the updates will have completed.
    Could anyone tell me if this is the case or am I in for more nasty surprises as the days pass. (new computer purchased 29/5/12) by the way I am now using wired instead of wireless I shouldn't think that would make any difference though!!!
    Thanks Patty-L
    Edit  I am on 10Gb monthly allowance
    Solved!
    Go to Solution.

    john46 wrote:
    the use of i player when using BT vision may show on your monthly usage but is deducted as it is routed differently when it comes to any monthly usage
    Actually, the BTVision element should never show on the online usage monitor. It will of course show on the hub usage.
    This is, in my view, one of the reasons why the usage monitor is done daily in arrears, to exclude the relevant items such as vision and bbtalk.
    http://www.andyweb.co.uk/shortcuts
    http://www.andyweb.co.uk/pictures

  • First day in month

    Hi,
    i need fm that bring the first day of next month,
    lif i put 01052008 i get 01062008
    or 15022007 get 01032007.
    Regards

    Hi,
    For Year
    Use FM: FIRST_AND_LAST_DAY_IN_YEAR_GET
    DATA:DATE1 TYPE D.
    DATA:DATE2 TYPE D.
    CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
      EXPORTING
        I_GJAHR        = SY-DATUM+0(4)
        I_PERIV        = '24'
      IMPORTING
        E_FIRST_DAY    = DATE1
        E_LAST_DAY     = DATE2
      EXCEPTIONS
        INPUT_FALSE    = 1
        T009_NOTFOUND  = 2
        T009B_NOTFOUND = 3
        OTHERS         = 4.
    IF SY-SUBRC  0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE: 'First Day', DATE1, 'Last day' , DATE2.

  •  hello actually I have purchased my iPod touch 4 generation 1 month back.initially I find that it's battery life is superb.it works for 5 -6 days in standby and 8-9 hrs usage time but from past 2days its battery list draining very fast I have to charge i

     hello actually I have purchased my iPod touch 4 generation 1 month back.initially I find that it's battery life is superb.it works for 5 -6 days in standby and 8-9 hrs usage time but from past 2days its battery is draining very fast I have to charge it twice a day.i m using iOS 6.0.1.plz suggest me what to do??its just 1 month old ..I have spend lot of money to buy it, I don't want it like that..plz reply.....

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Then see if placing the iPod in airplane mode when in standby helps.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:
    iOS: How to back up
    - Restore to factory settings/new iOS device.
    -  Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar

  • First Day of Month - CR 2008

    Hi experts,
    What's the code of First Day of Month?
    For example, AsOfDate : 10/29/2011, I want to get 10/01/2011 from 10/29/2011. I made it like follow, but I believe there is a simple code.
    CDate(ToText(DATEPART("m", ),0,'') + '/1/' + ToText(DATEPART("yyyy", ),0,''))
    Thanks,
    David

    Hi
    Try the follwoing :
    currentdate - day(currentdate)+1
    Note : replace currentdate with your date field.
    Thanks,
    Sastry

  • My Iphone 4 just updated to the iOS6.  I've connected it to my computer for the first time since then, and wanted to back up my photos in iPhoto.  However, although Iphoto recognized my phone, it shows no photos to upload or backup. ??

    My Iphone 4 just updated to the iOS6.  I've connected it to my computer for the first time since then, and wanted to back up my photos in iPhoto.  However, although Iphoto recognized my phone, it shows no photos to upload or backup.  It lists my phone in the "devices" category on the left bar, but no longer shows any of my photos.
    Does anyone have any suggestions?

    I've reread your question several times and am not sure I understand it.
    Are you trying to basically start over, as if you just took your iPhone out of the box?  If so, do:
    Settings > General > Reset > Erase all content and settings

  • Default value of date as first day of month

    Ho can I make my default value of date parameter as first day of month? {$SYSDATE()$} gives only current date and we can make it like {$SYSDATE()-7$} if we want to minus 7 days but how can we set the default value to first day of month?

    I got the answer...It is {$FIRST_DAY_OF_MONTH()$} instead of {$SYSDATE()$}

  • First day on iCloud and not a fan!

    First day on iCloud and not a fan! ... Why isn't it working. I don't mind changes only when they are improovements, but make sure it works before you make us all switch over.

    I don't have a problem here, but if you look at the latest posts here there seem quite a few who are, perhaps it's location specific, you might want to add your location to your profile and take a look at some of the other threads on this topic.

  • I have creative cloud, I have both photoshop and lightroom current versions installed - I was using the trial period.  I paid for the 9.99 a month and now I'm trying to figure out how to get a current program so it won't expire - which is still says it is

    I have creative cloud, I have photoshop and lightroom current versions installed - I was using the trial period.  I paid for the 9.99 a month and now I'm trying to figure out how to update this. 

    You need to uninstall the trial applications and reinstall from the CC app.

  • I have had my I have had my iPhone 5c for a little over a month and people can never hear me during calls, like I'm in a tunnel or muffled! I googled this issue and several others have had this problem as well. What can I do to get help?

    I have had my I have had my iPhone 5c for a little over a month and people can never hear me during calls, like I'm in a tunnel or muffled! I googled this issue and several others have had this problem as well. What can I do to get help?

    Take it in to an Apple store or authorized service center for evaluation and possible replacement.

  • ABAP for the first day of the month

    Hello BW users,
    I have a scenario which uses an ODS with cumulative key figures with Addition update type. An infocube gets data from ODS by start routine in cube's update rule. I update this ODS first then infocube. All the loads are Full and are loaded daily. This is a snapshot scenario and I load the ods on itself then load from another infocube let's say Cube1. After successful load, I update infocube on itself again then update from the same infocube, Cube1, as in ODS. Infocube load sequence is same as ODS. In the scenario ODS and infocube are wanted to be updated daily. Therefore, I have to delete the ODS's (since it is addition update type) and infocube's overlapping data in the process chain that automates the load. At this point I need two things:
    1- ABAP program that is going to give me the first day of each month.
    2- ABAP program that is going to delete the overlapping data in ODS when I load it daily. Since I can do that for infocube in process chain with standard process type of Delete overlapping requests from infocube I need it only for ODS. Because there is no standard process type to delete overlapping requests in ODS (since its update type is Addition).
    I appreciate your help. Thank you in advance.
    Sincerely,

    1- ABAP program that is going to give me the first day of each month.
    if sy-datun+6(2) = 01.
    SY-FDAYW should give you the day
    endif.
    2- ABAP program that is going to delete the overlapping data in ODS
    REPORT  <PGM NAME>.
    TABLES: RSODSACTREQ , rsseldone.
    Parameters : odsname type RSINFOCUBE default '<>ODS NAME'.
    DATA: temp_REQUEST LIKE RSODSACTREQ-REQUEST,
          temp_REQUEST1 LIKE RSODSACTREQ-REQUEST,
          temp_RNR LIKE rsseldone-RNR.
    DATA: BEGIN OF itab OCCURS 0,
          REQUEST LIKE RSODSACTREQ-REQUEST,
          TIMESTAMP LIKE RSODSACTREQ-TIMESTAMP,
          END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0,
          RNR LIKE rsseldone-RNR,
          seldate LIKE rsseldone-seldate,
          seltime LIKE rsseldone-seltime,
          END OF itab1.
    SELECT REQUEST TIMESTAMP FROM RSODSACTREQ INTO TABLE itab
      WHERE ODSOBJECT = '<ODS NAME>'.
    SORT itab DESCENDING BY TIMESTAMP .
    READ TABLE itab INDEX 1.
    temp_REQUEST = itab-REQUEST.
    SELECT RNR seldate seltime FROM rsseldone INTO TABLE itab1
      WHERE source = '<Info Source Name for the ODS>'.
      SORT itab1 DESCENDING BY seldate seltime .
      READ TABLE itab1 INDEX 1.
      temp_RNR = itab1-RNR.
    *If   temp_REQUEST = temp_RNR .
    CALL FUNCTION 'RSSM_PROCESS_REQUDEL_ODSO'
      EXPORTING
        I_ODS             = odsname
        I_REQUEST         = temp_REQUEST
        I_JOBNAME         = 'i_jobname'
        I_VARIANT         =
        I_INSTANCE        =
      IMPORTING
        E_ERROR           =
        E_T_MSG           = itab1
      E_T_RNRLIST       =    ITAB1.
    *else.
    *raise exception.
    *endif.
    clear itab.
    refresh itab.
    SELECT REQUEST TIMESTAMP FROM RSODSACTREQ INTO TABLE itab
      WHERE ODSOBJECT = '<ODS NAME>'.
    SORT itab DESCENDING BY TIMESTAMP.
    READ TABLE itab INDEX 1.
    temp_REQUEST1 = itab-REQUEST.
    if temp_REQUEST = temp_REQUEST1.
    raise exception .
    endif.

Maybe you are looking for

  • Announcement: Super 4.00 - a suite of EJB/J2EE monitoring/admin tools.

              Announcement: Super 4.00 - a suite of EJB/J2EE monitoring/admin tools.           Acelet is the leader in J2EE tools area. If you google "j2ee tools",           "j2ee logging", "j2ee scheduler" or alike, you will find Acelet           is at

  • Call url from ABAP program

    Hi friends, Can we call a web URL from a ABAP program? Is there anyway its possible ? if yes how? Please provide the solution. Thanks & Regards kapil

  • Doubts in BPM-- N:1 and 1:N scenario

    Dear all, I have a requirement where in some 10 files are placed at a location. The interface needs to consolidate/collated these files and generate a single file and send it to the target system after transformation. The reverse process also needs t

  • Retrieve key by value in Hashtable

    Hello everyone, I am wondering what is the most effective approach of retrieving key by value in a Java build-in Hashtable. Can anyone provide sample source codes? Thanks in advance, George

  • XML class generator error

    Hi all: I've download the XDK and I got the error when I try to run the demo by typing following command xmlcg -d CG.dtd sample.xml "Failed to initialize parser, code 201" Any help will be very appreciated Regards Ivan Chung