Need records from the last month

Hi, using Oracle 11g R2.
On the last day of each month of each year, I'd like to query data from a table over the last month. For example, if today is December 31st, 2013, I'd like to query only records with a settlement_dt between (and including) Dec 1, 2012 and Dec 31, 2012. My process will run automatically at the end of each month, so I can't hard code the date values. I've developed the following solution, but I was wondering if anyone had other ideas.
TO_CHAR(io.settlement_dt, 'MON')||TO_CHAR(io.settlement_dt, 'YYYY') =
                               TO_CHAR(SYSDATE, 'MON')||TO_CHAR(SYSDATE, 'YYYY')
Thanks!

Hi,
The most efficient way is
      io.settlement_dt >=             TRUNC (SYSDATE, 'MONTH')
AND   io_settlement_dt <  ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), 1)
This will allow the optimizer to use an index on io.settlement_dt.  Also, it involves only 3 function calls, regardless of how many rows are in the table (that is, no function has to be called for every row).

Similar Messages

  • My phone has been smashed I need to get records of all my iMessages and texts from the last month. How do I get these?

    My phone has been smashed I need to get records of all my iMessages and texts from the last month. How do I get these?

    Do you have a backup of your iPhone which contains these messages?
    If so, you can restore a new iPhone from that backup during setup.
    If not, the messages are gone.

  • I need to redownload songs from the last month. Is there any way to do this through itunes?

    I had to get a new ipod touch through a warranty because of technical problems so I could not transfer my last few purchases (about one month).  Is there any way that I would be able to get these downloads back with out redownloading my entire library.

    From the iTunes Help menu...
    "It’s important to make backups of your purchases from the iTunes Store. If you lose a purchased item for any reason and haven’t backed it up, you’ll have to buy it again."
    With iTunes open, from the menu bar click Help / iTunes Help.
    In the search field on the right type in backup
    Select:  Back up your iPod touch, iPhone, or iPad
    I had to get a new ipod touch through a warranty because of technical problems
    Unfortunately, if you didn't backup your iTunes media to an external source, you might be out of luck but, click here.
    http://www.apple.com/support/itunes/
    Then click: iTunes Store Account and Billing
    Then click: Billing Inquiries
    Then click: Email.
    Stranger things have happened where Apple bent a rule or two.

  • Need to remove all app purchases from the last month.

    My son took my ipod and bought over 200 dollars worth of goods from the appstore can anyone help my remove them?

    You can try contacting iTunes Support and see if they will refund or credit you : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
    To try and stop it happening again you can use Settings > General > Restrictions to turn off in-app purchases and to require your account's password to be entered for every purchase (the default is a 15 minute period during which it doesn't need re-entering).

  • Need to DELETE and LOAD data of the Last month to

    Hi Experts,
    I need to delete the last month data from cube because One material is not updated with a Required value. We have made some changes in Update routine for a Value. The Same change must be reflected from last month of data ,
    So I need to delate the data based on selection. And reload  the data again. And the data flows from
                                               2LIS_13_VDITM (Info Source ) to ZSD_C03 (Info Cube). 
    I read many SDN threads, but I am getting confused.
    How can I proceed for these  ?
    Thanks,
    Utpal.

    Hi Srikanth,
    Thank you for responding.
    I had a problem on one material. So deleted the request and Reload it from PSA. That issue got solved.
    And Now the problem is , Now my senior is saying Delete the data from April-09 till date and Reload it. The issue is My CUBE ( ZSD_C03 ) is updated with 4 data sources. 2LIS_11_V_ITM   ,  2LIS_13_VDITM   ,  2LIS_12_VCHDR  , 2LIS_11_VAITM .
    And I need to delete data from 2LIS_13_VDITM  data source . How Can I proceed for the current issue   ?
    Please suggest   ...
    Thank you ,
    Utpal

  • Need to fetch the last record/row from a table

    Hi,
    I have a requirement like fetching the closing balance of the last record of the table and inserting the same into the opening balance of the immediatetly created next record.
    In simple words, I need to fetch a value from the last row of the record.
    For example, I use the below query,
    select rownum, empno, ename from emp
    where rownum = (select count(rownum) from emp);
    But, the above query does not return any of the record.
    Hence, need help on this.
    Regards,
    Shivakumar A
    Edited by: shiva on Mar 27, 2011 10:14 PM

    Rows in a table are inherently unordered. In order to introduce the concept of "first" and "last", you would need to specify how to order the rows which would require that there was one or more columns in the table that you could order by in order to determine the "last" record.
    In your closing balance example, if we assume that there is something like a BALANCE_DATE column,
    SELECT account_number, balance_amount, balance_date
      FROM (
        SELECT account_number,
               balance_amount,
               balance_date,
               rank() over (partition by account_number order by balance_date desc) rnk
          FROM table_of_balances )
    WHERE rnk = 1Justin

  • SQL query to get last 6 months records neglect the current month

    Hi All;
    I need help with 
    sql query to get last 6 months records neglect the current month
    Any help much appreciated
    Thanks
    Pradnya07

    SELECT <> FROM tbl WHERE dt >=dateadd(month,-6,GETDATE())
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • For the last month or so my icloud won't back up, it keeps telling me that there is too much storage and I need to delete some data. But I have deleted between 3-400 photos and it is still saying the same, can anyone please help

    For the last month or so my icloud won't back up, it keeps telling me that there is too much storage and I need to delete some data. But I have deleted between 3-400 photos and it is still saying the same, can anyone please help

    If they were deleted from your camera roll that should have resulted in a corresponding decrease in the estimated size of your next backup.
    If it's still saying that you don't have enough storage to back up, read through this article: http://support.apple.com/kb/ht4847.  It provides some suggestions for reducing your iCloud storage, such as deleting unneeded email. 
    The other area to look at is your text messages.  These are included in the backup.  If you have lots of photos and videos attached to your messages, that can significantly increase the size of your backup.  If that's the case, deleting these may make a big difference.

  • Need to find the last day of the previous month

    hi folks,
    the code goes like this...
    data: xt247 type t247,
          monthn(30) type c,
          monthnumber type i,
          bforwardmonth type i.
    call function 'RP_LAST_DAY_OF_MONTHS'
      EXPORTING
        day_in            = s_date
      IMPORTING
        last_day_of_month = e_date.
    write: 'The last day of the month', e_date.
    select single * from t247 into xt247
            where spras = sy-langu
              and mnr = e_date+4(2).
    monthnumber = xt247-mnr.
    write:' The month number', monthnumber.
    determine the previous month.
    bforwardmonth = monthnumber - 1.
    From here I need to determine the last day of the previous month How can I do?
    Thanks for your help.
    Santhosh

    Hi all,
    here's the shortest solution:
    REPORT z123.
    PARAMETERS p_datum LIKE sy-datum DEFAULT sy-datum.
    DATA ultimo  LIKE sy-datum.
    <b>ultimo = p_datum - p_datum+6(2).</b>
    WRITE: / p_datum, 20 ultimo COLOR 2.
    it's not my solution :
    it's from <a href="http://www.abapforum.com/forum/viewtopic.php?t=1434&highlight=ultimo">Andrew_</a>
    regards Andreas

  • I have a problem in iphone4,i am from india and bought a new unlocked iphone4 from USA last month.the problem is when i call someone their is disturbance in the voice and i cant hear the opposite person voice.please inform me how should i overcome this?

    I have a problem in iphone4,i am from india and bought a new unlocked iphone4 from USA last month.the problem is when i call someone their is disturbance in the voice and i cant hear the opposite person voice.please inform me how should i overcome this?

    There may be a defect in the phone. As you bought it in the US the only place you can get it looked at is in the US.
    When you say you bought it new, unlocked did you buy it directly from an Apple store? If you did not it was hacked to unlock it, which could also be your problem. Apple stores are the only place in the US that sells legitimately unlocked iPhones.

  • I have an iMac5,1 with an intel processor.  For the last month or so, whenever I play a video from an outside source - e.g. YouTube, the picture jumps and breaks-up.  All of my software is up-to-date.  Any thoughts on how to fix this problem?

    I have an iMac5,1 with an intel processor.  For the last month or so, whenever I play a video from an outside source - e.g. YouTube, the picture jumps and breaks-up.  All of my software is up-to-date.  Any thoughts on how to fix this problem?

    You're welcome. As to checking speed go to http://speedtest.net/ and it will choose the closest server for you. BTW, whatever you do, don't click on the robot icon that says "Start Scan" or MacKeeper below that. Only use the speed test in the middle that has the button BEGIN TEST on it. It will run a download speed test first and then an upload speed test. The download test will give a much faster response.

  • How to "remember" data from the last or the first record printed on a page?

    I'd like to put a column value from the last record printed on the first page into a placeholder column (or whereever) to use later but I haven't found any way to do that. Trying the assignment statement with a placeholder in a format trigger causes "REP-1323: Cannot have output columns in format trigger...". Any ideas?

    Hi,
    SQL> select * from EMailNotify;
            ID TO_ADDRESS
             1 [email protected], [email protected],[email protected], ma.ram @test.com,[email protected]
             2 [email protected], [email protected],[email protected], ma.ram @test.com,[email protected]
             3 [email protected], [email protected],[email protected], ma.ram @test.com,[email protected]
    SQL> update EMailNotify
      2  set to_address=replace(to_address,' [email protected],','');
    3 rows updated.
    SQL> select * from EMailNotify;
            ID TO_ADDRESS
             1 [email protected],[email protected], ma.ram @test.com,[email protected]
             2 [email protected],[email protected], ma.ram @test.com,[email protected]
             3 [email protected],[email protected], ma.ram @test.com,[email protected]

  • My iphone 5c crashed after updating to IOS 8.02 and now i don't have anything from the last 3 months. What do I do?

    My iphone 5c crashed after updating to IOS 8.02 and now i don't have anything from the last 3 months. What do I do?

    Don't worry about that. iPhone stuck in recovery mode always happens when you update the iOS on your iPhone. There are two ways to solve it.
    First is is to put your iPhone in DFU mode.
    Step 1. Turn off iPhone
    Step 2. Hold down the Power and Home button.
    Step 3. When you see the Apple logo, release the power button but continue holding the Home button down.
    Step 4. Open iTunes and wait for it to tell you that it’s in restore mode.
    If DFU mode can't solve the problem, I'm afraid the only solution is to try some 3rd party software, like iPhone data recovery or something like that. You may simply try the tutorial here: How to Fix iPhone that is Stuck in Recovery Mode.

  • I am doing a photo book but can only place picture from the last 12 months or last import. How can I access other pictures? Any advice?

    I am doing a photo book but can only place picture from the last 12 months or last import. How can I access other pictures? Any advice?

    You access them in the event they are in or under Photos or from an album if they are in an album - simply drag them to the book project in the source pane on the left
    LN

  • My phone's earphone doesn't work which was bought from USA last month,the china apple store didn't accept the free repaired,so what can i do now?

    my new iphone5s's earphone doesn't work which was bought from USA last month,probably it was cause by falling down on floor insidentally one day before I came back china , the problem is ,the china apple store didn't accept the free repaire even the phone was bought only one month age, I was so disappointed and realized the iphone 5s is so  fragile,although I previous iphone4 which was also bought from USA 4 years age, it also fell down many times, it still works well now.  what can i do now? send it back to USA for repairing? if like that,it will take almost two month to finish the all processes,that not only waste the time spent on the way, also waste expense on the expense,the important prlblem is,  I can't use the phone during the repairing~ please give me a solution as soon as you can ,thank you very much!

    You can send it to someone you know in the US to have them take it in for service or you can get on a plane and take it there yourself. You can not ship it to Apple in the US for service.

Maybe you are looking for

  • Is it possible to build a reliable application with the flash datagrid ???

    Hello all, Next problem in my non-stop nightmare using a flash datagrid to build an application I have a datagrid in my movieclip. Under Windows, if I select a row of the datagrid in read-only mode, let's say row 10 on screen, if I then switch the Wi

  • Contact pics not displaying in Messenger

    Is this a prolem with BB 6.0?

  • Problem using javascript function?

    Hallo, i integrate a file for javascript functions with this code <afh:head title="#{res['pob.login']}"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15"/> <script type="text/javascript" src="../Javascript/Funktionen.js"></scr

  • How to Reprocess Outbound Idocs in Status 02 (Errors)

    Hi,     I have an urgent problem. How do I re-process an Outbound IDoc in Status '02' (Error Passing Data to Port)     I have tried reprocessing this IDoc through BD87 using both the options Edit>Process and Edit>Restrict and Process, but it doesn't

  • Account in the System Preference Crash

    Every time I try to go into Account in the system preferences, it crashes. Any thoughts? All the other panes load fine. I've just delete com.apple.finder.plist in my preference and repaired permission. I'm running 10.6.1