Current month data: Help needed to change this code a return procedure

Hello people I this scenario where I need to change the code so that there return data compared to the month current day to the day before if it's a daily report and data from the months preceding it is a monthly report.
I have no idea how to change this code below. Currently the code returns the data of the monthly reports for the previous month. Someone has any idea how to change so that the code meets the requirements of daily and monthly reprts.



BEGIN

If v_lowdate is null or v_highdate is null then
Select to_number (to_char (sysdate, 'DD')) double v_cur_day;
If v_cur_day < 25 may
-It's for the month to run
Select Add_Months (trunc (sysdate, 'MONTH'), - 1).
IN V_LOWDATE
FROM DUAL;

SELECT Last_Day (ADD_Months (Sysdate-1)) INTO V_Highdate From Dual;
on the other
-This is for the current delivery month
Select trunc (sysdate, 'MONTH') IN V_LOWDATE FROM DUAL;

SELECT Last_Day (Sysdate) IN the double V_Highdate;
end if;

end if;




Thank you

Published by: user11961230 on September 30, 2009 20:34

Hello

The revised version of the code below, statement a daily report on every day except the 1st of the month, will include the dates of the first of the month through yesterday.
If a daily report is requested on the 1st of the month, then it will start the 1st of the month form last through yesterday (which is the last day of the previous month, making it the equivalent of a monthly report). I've added comments in the code on the lines that check these things.

v_cur_day := TO_CHAR (SYSDATE, 'DD');

IF  report_type = 'D'                         -- Daily report
AND v_cur_day > '01'                         -- (except when run on 1st of the month)
THEN                                   -- will cover from

     v_lowdate  := TRUNC (SYSDATE, 'MONTH');          -- 1st of this month to
     v_highdate := TRUNC (SYSDATE - 1);          -- yesterday
ELSIF  report_type = 'M'                    -- Monthly report
OR     (     report_type = 'D'               -- (or Daily report
       AND     v_cur_day = '01'               -- if run on the 1st of the month)
       )                              -- will cover from
     v_lowdate  := ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                     , -1
                     );               -- 1st of last month
     v_highdate := TRUNC (SYSDATE, 'MONTH') - 1;     -- last day of last month
END IF;

The above code always makes all the previous month, a monthly report. If you decide you want to want to do the month in progress (not the previous month) when a monthly report is run the or after the 25th of the month (as your original code), then use the version below:

v_cur_day := TO_CHAR (SYSDATE, 'DD');

IF  report_type = 'D'                         -- Daily report
AND v_cur_day > '01'                         -- (except when run on 1st of the month)
THEN                                   -- will cover from

     v_lowdate  := TRUNC (SYSDATE, 'MONTH');          -- 1st of this month to
     v_highdate := TRUNC (SYSDATE - 1);          -- yesterday.
ELSIF  (     report_type = 'M'               -- Monthly report
       AND     v_cur_day <= '24'               -- (if run between the 1st and 24th,
OR     (     report_type = 'D'               -- or Daily report
       AND     v_cur_day = '01'               -- if run on the 1st of the month)
       )                              -- will cover from
     v_lowdate  := ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                     , -1
                     );               -- 1st of last month to
     v_highdate := TRUNC (SYSDATE, 'MONTH') - 1;     -- last day of last month.
ELSIF  (     report_type = 'M'               -- Monthly report
       AND     v_cur_day >= '25'               -- (if run on or after the 25th of the month)
       )                              -- will cover from
THEN
     v_lowdate  := TRUNC (SYSDATE, 'MONTH');          -- 1st of this month to
     v_highdate := LAST_DAY (TRUNC (SYSDATE));     -- last day of this month
END IF;

Tags: Database

Similar Questions

  • I need to change my code IBAN Bank during the session on payments. How can I do? Thank you

    I need to change my code IBAN Bank during the session on payments. How can I do? Thank you

    I think you must contact Adobe personnel to help

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

  • Help! Need to change this statement to a Count (*)

    Please help me to change it to a Count (*), because I don't want to see the detail.

    Select distinct
    partner, region, od. ORDER_AFFILIATE_NAME,
    Oh.external_order_number,
    Ain.get_g1 (queue_type) offers,
    Case
    When disp.category = 100 Then 'ORDER'
    When disp.category = 200 Then 'ACCESS'
    When disp.category = 300 Then 'DSL'
    When disp.category = 600 Then 'IPTV'
    "When disp.category = 700 Then'INTERNET"
    When disp.category = 800 Then 'VOIP'
    End up like product_category,
    To_char(OH.created_ts, 'yyyy-mm-dd HH24:mi:ss') CREATE_DATE

    -Case when ip.offer_type = "IPDSLAM" or instr (ip.display_name, "-d") > 0
    THEN 'IP - LAN'
    ELSE 'FTTN.
    end as product_type

    Case
    When disp.state = 4 and disp.state = 9 or disp.state = 21 or 22 = disp.state then 'cancelled '.
    When disp.state = 17 then "NRFC cancelled.
    When disp.state = 7 Then 'incomplete '.
    When disp.state = 3 or disp.state = 8, then "Finish".
    When disp.state = 6 or disp.state = 10 and disp.state = 13 or disp.state = 14 then 'pending - other ".
    When disp.state = 19 disp.state = 20 then "sent".
    When disp.state = 21 or disp.state = 22 then "Cancelled - CSUS.
    When disp.state = 23 or 24 = disp.state then 'Order Confirmation '.
    When disp.state = 1 or disp.state = 2 or disp.state = 15 then "receipt".
    Another 'other '.
    End as STATE_desc


    of AIN.impl_oh_order_header oh,.
    Ain.impl_order_data od,
    DISP AIN.sncr_order_curr_disp,
    AIN.impl_package ip
    where oh.created_ts between to_date ('2013-02-04', ' yyyy-mm-dd "")
    and to_date ('2013-02-11', ' yyyy-mm-dd "")
    and oh.order_type = 'COMMAND '.
    and disp.category to (200, 300, 600, 700, 800)
    and disp.state! = '5'
    and uscs = 0
    and disp.transaction_id = oh.transaction_id
    and od. transaction_id = oh.transaction_id
    and ip.transaction_id = oh.transaction_id
    and ip.package_type = 'PACKAGE '.
    and ip.parent_package_id is null
    and ip.product_type = 'COMMAND '.

    FORUM THREAD IN DOUBLE AND EVIL!

    Please mark this ANSWER question you have posted in the wrong forum, and now you have it posted in the SQL and PL/SQL forum where it belongs.
    Help, please! Need to modify this Script to do a Count (*)

  • Need to change "this notification requires no response."

    Dear Experts,

    I'm new to the workflow.  I did notice FYI, but action is needed from the link in the notification. It shows "Information this notification does not require a response" as it is a notification of FYI.

    My customer requests to change this as "this notification requires your answer."

    Please suggest me that there is that no workaround is here to change.

    Thanks in advance.

    Kind regards

    Muthu

    You may need to change the standard model was used for FYI that is usually: Workflow Open for info Mail

    It will be a part of the article standard system: type of item of Mailer (WFMAIL).

    Download the WF Designer:

    Note 261028.1

    Title: How to download and install the latest Workflow Oracle

    Constructor (Client tool) for the E-Business 11i

    Steps to follow:

    1. open the generator and access the instance to open the system item: item of Mailer (WFMAIL) type.

    2. expand the 'Message' section to locate: Workflow Open FYI Mail (OPEN_MAIL_FYI).

    3. click on the message and access the body TAB to change the current model from

    Oracle Workflow notification (for info)

    & COMMENT

    ________________________________________________________________________

    & BODY

    TO

    "This notification requires your answer."

    4. save the changes.

    5. the load to the server and validate.

    If you consider your question/problem answered/resolved,

    Please do not forget to mark the Correct/good responses in the thread. It helps other users of the community to identify the solution quickly!

    Kind regards

    Ajith

  • help desk jet series 6210 need to change region code

    I have a 6210 printer office jet purchased in South Africa. Must be able to use in the United States with wagon no 94 / & 95 but I need to change the region code.

    Is your printer still in the period of one year standard warranty?

    Contact HP Total Care. A service representative will be able to guide you through a change of region by telephone.

  • How can rejection of the Amazon - the link to Adobe AIR in your app update needs - I change this

    Here is a message I received from Amazon:

    Unit tested : Motorola Droid (2.3), HTC Evo (2.3.3), Samsung Galaxy Tablet (2.2)

    Question : The link in your Adobe AIR application must be updated so that visitors are taken directly to the page of Adobe AIR app on the Amazon Appstore. The download URL is http://www.amazon.com/gp/mas/dl/android?p=com.adobe.air steps: I) launch the application. (II) press 'Install' > > «Appstore» Observe that the application accesses the home page of the Amazon app store for Adobe Air installation.

    I'm guess I could change this in my xml file:

    I change the URL in this line than what they provided (http://www.amazon.com/gp/mas/dl/android?p=com.adobe.air):

    <? XML version = "1.0" encoding = "UTF-8" standalone = 'no '? >

    " < application xmlns =" http://ns.Adobe.com/air/application/2.6 ">

    However, when it is published it always changes it back to the old address. How to prevent this?

    Thank you.

    I think I found the couresty of Benny 7500 response on August 11, 2011 09:18.

    For me the work of editing the file Markets.xml to:

    "C:\Program Files\Adobe\Adobe Flash CS5.5\en_US\Configuration\Android\Markets.xml"

    and the replacement of key of Amazon Appstore

    http://www.Amazon.com/GP/MAS/DL/Android?p=com.Adobe.air"/ >

    That's all!

  • How to change this code?

    This code creates an external text file scroll on the stage. I want to modify it so that it continues to scroll when the mouse is moved down, as the moving text, a little bit on each mouse click seems useless to me. Thank you, jcarruth.
    ------------------------------------------------------------------------------------------ -----------------------------------------
    var external_txt:TextField = new TextField();
    var externalReq:URLRequest = new URLRequest ("external.txt");
    var externalLoad: URLLoader = new URLLoader();
    externalLoad.load (externalReq);
    externalLoad.addEventListener (Event.COMPLETE, textReady);
    up_btn.addEventListener (MouseEvent.CLICK, scrollUp);
    down_btn.addEventListener (MouseEvent.CLICK, scrollup);
    external_txt.x = 175;
    external_txt.y = 100;
    external_txt. Border = true;
    external_txt. Width = 200;
    external_txt. Height = 200;
    external_txt.WordWrap = true;
    addChild (external_txt);
    function textReady(event:Event):void
    {
    external_txt. Text = event.target.data;
    }
    function scrollUp(event:MouseEvent):void
    {
    -external_txt.scrollV;
    }
    function scrollDown(event:MouseEvent):void
    {
    external_txt.scrollV ++;
    }

    :

  • Help, please! Why this code work in 6i form and does not work in forms 11g

    I tried to fix this thing for weeks and for some reason that I can't understand how to operate.

    Here are the error codes I get:

    FRM-41219: can not find the report: invalid ID (this pop on the screen I then click on the ok button the next show at the bottom of the screen)

    FRM-40738: Argument 1 of builtin RUN_REPORT_OBJECT cannot be null

    Basically, this code is supposed to call a report that puts another screen pop up and display the report.

    Here is the code behind the button on the form "File Print".

    :OVERALL. THE_NUMBER: =: REQUEST_SEQUENCE;

    IF : REQUEST_AMOUNT<100000 THEN : TEXT_ITEM83: =: request_amount;

    ELSIF : REQUEST_AMOUNT> THEN 1000000 : TEXT_ITEM83: =1;   / * I think the ELSIF should be replaced with ELSE IF don't know * /.

    END IF;

    : TEXT_ITEM74: =:GLOBAL. THE_NUMBER;

    THE_REP;

    Here is the code that is behind the box of quere.

    Start

    : global .qry_rep_val: =: quy_rep;

    : display_item78: =: global .qry_rep_val;

    If: global .qry_rep_val = '3' then null;

    elsif: global .qry_rep_val = 1 then

    run_vba_rep1;

    elsif: global .qry_rep_val = 2 then

    run_report_for_last_query;

    elsif: global.qry_rep_val = 4 then / * Yes, there is an extra space between the two, the 'val' and '='. Should I delete TI * /.

    Call the form ('/ export/home/oracle/Middleware/Oracle_FRHome1/forms/vba_tda_qry ', HIDE, NO_REPLACE, QUERY_ONLY);

    end if;

    : qry_rep: = 3;

    end;

    I guess that the problem is in the run_report_for_last_query procedure. There will be something like run_report_object. Could you post this code?

  • Can someone help me to crack this code

    Hello

    I'm working on a few different scripts to complete the banners... Recently, I came across this one and I do not understand cant someone expian for me...

    Basically, the banner is on the maintimeline and the code is as follows in each of these images:

    Section 1:

    var maxPlays:Number = 4;

    If (timesPlayed == undefined) {}

    var timesPlayed:Number = 3;

    Section 45: (where the movie finally stop playing for good:)

    If {(stopEarly)

    stop();

    }

    Frame 80: last image of the timeline:

    If (timesPlayed < maxPlays) {}

    timesPlayed ++;

    gotoAndPlay (1);

    } else {}

    stopEarly = true;

    gotoAndPlay (1);

    }

    Some of my random Questions are:

    If the loops of film 3 times, why this var maxPlays = 4

    also, in the last line of code on frame 80 - gotoAndPlay (1); -If it stops at this place of stopEarly, why is this line? It seems to work without it as well, but I'm curoius why it's here.

    Anyhelp tellimh me how this code is greatly appreciated!

    Thank you

    Babs

    There must be a two other lines on frame 1:

    var timesPlayed;

    var stopEarly;

    Or the code would not work.

    Seems sort of hackey, but I'll walk through you it:

    Framework 1, play 1:

    timesPlayed is not defined, so it gets the value 3.

    45 1 frame game:

    stopEarly is not defined, which is false, then the read head keeps going.

    80 1 frame game:

    3 is less than 4, so timesPlayed gets incremented to 4 and at the playhead is moved to frame 1.

    Frame 1 exhibit 2:

    nothing happens (it is not indefinite of timesPlayed).

    45 2 frame game:

    stopEarly is not defined, which is false, then the read head keeps going.

    80 2 frame game:

    4 is not less than 4 stopEarly Yes Gets the true value and the playhead is moved to frame 1.

    Frame 1 Exhibit 3:

    nothing happens (it is not indefinite of timesPlayed).

    45 3 frame game:

    stopEarly is true, then the read head is stopped.

    To make the code more understandable, timesPlayed should be set to 1 instead of 3 if it is not set, this way maxPlays will actually represent the maximum number of full game-through.

  • Hello! Is there a way to create a shortcut that allows you to toggle the checkbox "Allow pages to choose their own colors, instead of my selections above" located in Tools/Options/content/colours? I need to change this setting repeatedly and need to speed

    I looked for the Add - ons that could automate this configuration change, but nothing helped. Only actions of web page can be saved in a macro, but no change in configuration.

    A shortcut to access the appropriate dialog box would help as well. I could manually check / uncheck box saving all stages several necessary to get there. But I don't him not found anywhere.

    I thank very you much for any help you can provide me.

    Best regards

    Alex

    I have a checkbox on the PrefBar to pass this parameter (browser.display.use_document_colors).

    PrefBar can also assign a shortcut buttons and checkboxes.

  • Help needed to change the vision of the USB folder

    When I open the external hard drive, his point of view is like the thumbnail (a single file in the Middle above and others all to the baseline in a row). I want to change it to put all the files and folders on the screen as on the higher office. If someone could help would be appreciated.

    In the title bar of this window to the rt, click the drop down arrow (change your point of view)

  • I chose by mistake the prepaid and no monthly fee, how do I change this?

    Help, please!

    Hi Amanda,.

    If you have done in the last 30 days, I think that you can just cancel the annual prepaid and then buy w annual payments / monthly.

    Cancel your subscription or membership. Creative cloud

    If this does not work, follow the instructions to contact customer service and they should be able to straighten things.

    Kind regards

    Steve

  • clicked "never allow" for a program to run. need to change this.

    I recently downloaded the steam 2 Team Fortress and when I went to run the program, a window pops up with the buttons "never allow, allow once, always allow". I have been followed and accidentally clicked on never leave out. now when I try to run team fortress2 it closes every time. How can I change I can let it run?

    Haha! I just fixed it. Apparently if you just keep trying to open it I just have a window that came and said "firefox has noticed your attempts to this program. You want to allow it? "And I was able to change the setting. Thank you for your interest in this question tho.

  • Help me please with this code

    Hello

    It is the first program that I tried to write alone... and I'm stuck. I am trying to acquire data from a scope. I want the vi to load only the first field of application preparation time, the code is executed. Once the installation has been loaded, I want just the vi in order to reset the scope in order to acquire more data. I tried the first call, structures of the case,... all I can think about, but when I continually run the vi, it still loops and reloads the configuration every time. I have attached a picture of the code vi and describes the area of the code in question. The case structure is programmed to initialize the scope for open communications, then erase all existing data, and then call a program of specific scope to true. Wrong, I want only this setting of the code to initialize the communication within reach yet reminiscent of the configuration. A professional can explain it please how I'm supposed to accomplish this. Thank you

    If you use RUN continuously to keep something running, you are indeed pushing the button RUN every time it stops, the function PREMI¨¨RE will return TRUE every time.

    There are ways to do exactly what you're asking, but you are better off looking at the heart of your question:

    You need a loop.

    Put a loop around the part you want to do on several occasions.

    Create a STOP button to stop the loop.

    Make your INIT orders only once outside of the loop and make sure that the INIT part something happening in the WHILE loop

    (to make sure that the loop starts after INIT).

  • An urgent need to change the code PIN, don't want to factory reset

    Hi all

    A few weeks ago, I accidentally dropped my Xperia Z3 Compact on the ground. The damage was not serious, apart from a few scratches on the screen, at least, I thought. It turns out that the damage was much more than just some scratches: a few hours later, my touch screen started acting weird and finally the half top of the touch screen is not functional, as in the screen still worked, but I couldn't support what either on the upper part of the screen.

    You guessed it already: my PIN contains the number 1, and on the unlock screen, the number 1 is on the upper part of the screen, making it impossible for me to enter my full pin code. I want to reset the pin code, but I don't want my lost data.

    Things I've tried:

    -Device android Manager: everything is functional in the SMA: location works fine, I can ask a ring and I can probably delete my camera as well, but I have not tried. When I press the "Lock" option on the other hand, it does not work. I have a password on my PC and confirm. He invites even "Lock request successfully sent" or something in that direction, but when I look at my phone, nothing happens. When I try to enter a new password, it invites "since Google has verified that a screen lock is already set, the password you entered is not necessary." Looking at my phone, nothing happened.

    -Enter the code wrong PIN several times to connect with my Google account: I think it is already patched, but I tried anyway. My phone is locked for 30 seconds every time.

    Google search gives thinking I should factory reset my device so the PIN will be removed, but I got precious files on this phone, and not on a SD memory

    Would be just to back up my whole phone on a PC and factory reset it, but I can't access the files of the phone while it is locked.

    If anyone has a solution for my situation, it would be much appreciated.

    Thanks in advance

    Connect a USB mouse via the otg cable and use it to unlock.

Maybe you are looking for