Function to move all the dates for the previous Monday

Here's what I have:

create or replace
FUNCTION ToPreviousMonday
(DATE_FIELD IN date)
Date of RETURN
AS
BEGIN
IF TO_DATE (DATE_FIELD, 'DAY') = 'SUN' THEN (DATE_FIELD)-6;
Of ANOTHER trunc (DATE_FIELD, 'd.') + 1;
END IF;
END ToPreviousMonday;

Don't compile.

Basically, what I want to accomplish is in a SELECT statement, say something like (SELECT ToPreviousMonday (MyDateField) FROM MaTable) and cause the data back as the date of the previous Monday. NLS_TERRITORY is and will be for all the sessions going to Sunday as the day of the week 1.

Pointers?

Use:

TRUNC (DATE_FIELD, 'IW')

IW means ISO week which starts always on Monday regardless of NLS.

SY.

Tags: Database

Similar Questions

  • I had a hard drive crash and had to move all the data again. Now, I get an error saying that my Visa is not an authorized version. How can I find the product key to reactivate?

    Vista Product Code question

    I had a hard drive crash and had to move all the data again.  Now, I get an error saying that my Visa is not an authorized version.  How can I find the product key to reactivate?  I don't have the sticker on the back and the software I have does not have the code?  I bought this laptop DELL at Best Buy a little more than a year.

    Thank you.

    Hello

    This problem may occur if you make a significant hardware change. See the link provided below.

    Error message when you start Windows Vista: "your activation period has expired".

    http://support.Microsoft.com/kb/925616

    If the OS came preinstalled Dell you may need to contact Dell technical support for assistance.
    http://support.Dell.com/support/topics/global.aspx/support/win7_support/win7_portal?c=us&CS=04&l=en&s=BSD

  • Function to retrieve all the days of the previous month.

    Hello

    Yes, it's a monthly report, I received the task at hand.

    So, all I need is every day of the previous month (even if there is no data for that day)

    I was instructed to use the following code, but it does not return a value any:
    DECLARE
       CURSOR CUR_LAST_DAY IS
          SELECT TO_CHAR (LAST_DAY (ADD_MONTHS (SYSDATE, -1) ), 'DD')
            FROM DUAL;
     
       VVA_LAST_DAY   VARCHAR2 (2);
       --
       VNU_JOUR       NUMBER       := 0;
    BEGIN
       OPEN CUR_LAST_DAY;
     
       FETCH CUR_LAST_DAY
        INTO VVA_LAST_DAY;
     
       CLOSE CUR_LAST_DAY;
     
       WHILE VNU_JOUR <= TO_NUMBER (VVA_LAST_DAY) - 1
       LOOP
          VNU_JOUR := VNU_JOUR + 1;
       END LOOP;
    END;
    --CLOSE CUR_LAST_DAY
    --DEALLOCATE CUR_LAST_DAY
    -----
    On the other end, I developed this code:
    SELECT TO_CHAR(SYSDATE,'dd')
    FROM DUAL
    WHERE TO_CHAR(SYSDATE,'dd') >= to_char(to_date(to_char(ADD_MONTHS(SYSDATE, -1),'yyyy-mm')||'-01'),'yyyy-mm-dd')
    AND TO_CHAR(SYSDATE,'dd') < to_char(LAST_DAY(to_date(to_date(to_char(ADD_MONTHS(SYSDATE, -1),'yyyy-mm')||'-01'),'yyyy-mm-dd')));
    Which returns a null value. :(

    Concerning

    Hello
    You want to retrieve whole days of the month last query... So here's...

    SELECT
    TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY') COMP_DATE,
    TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'DD') ONLY_DD,
    TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'MM') ONLY_MM,
    TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'YY') ONLY_YY
    FROM DUAL
    CONNECT BY LEVEL <= TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(SYSDATE,-1)),'DD'))
    

    I'm not at the machine database so not tested.

    But one thing do not forget that this forum only for reports, it is a separate SQL and pl/sql instance.
    Function to retrieve all the days of the previous month.

    -Clément

    Published by: Graham on April 22, 2010 22:53
    Spelling error

  • How can I move all the information of the computer without having to hit F1 or F2 at startup and go directly to the windows desktop in Windows XP

    How can I move all the information of the computer without having to hit F1 or F2 at startup and go directly to the windows desktop in Windows XP

    see if this article applies to your question:

    http://www.computerhope.com/issues/ch000301.htm

    a method to determine if the motherboard (cmos battery) battery should be replaced is to monitor the time in the windows desktop.

    If windows does not have the exact time, then the motherboard battery is low and must be replaced.

  • timing issue with cruzer blade SCDZ50 - 008G: cannot move all the files from the PC to the USB

    I accidentally deleted this file synchronization that was in the main folder of the USB. now I can't move all the files from the computer to the cruzer blade. I can't find where to download it online. Help, please!

    Too bad. found this

  • Move all the clips on the right side of the crt in cs5

    This shortcut used to be + shift + m, but that seems to no longer work on cs5.

    How to move all the clips to the right of the cathode ray tube?

    It's been moved to A key.

  • TextFrame move to the previous position

    Hi Forum,

    Need help from you.

    After all the pageItems collection and resize (scale) to the new height page, I want to move the text Frames.geometricBounds [1] to the previous position before scaling were made.

    for example, before scaling: executives of related texts [i] .geometricBounds [1] is 12mm, 16.5 mm respectively.

    After consolidation and scaling of the group to the new height of page, I want to return the textFrames.geometricBounds [1] and 12 mm, 16.5 position.

    I tried to memorize the geometricBounds [1] frames of texts related to a table and after scaling was done, dissociated and tried to move all the frames of texts related to the previous position.

    var FO = app.activeDocument.textFrames.everyItem () .getElements ();

    for (i = 0; i < tf.length; i ++) {}
    var VAT = [];
    VAT.push(TF[i].geometricBounds[1].) Join ('\r'));

    Here scaling group is the new size of the page...

    If (tf [i]] .geometricBounds [1] < app.activeDocument.pages.item (0).marginPreferences.left;)

    {tf [i] .move ([tf [i] .parentPage, tf [i] .geometricBounds [0]]).}

    try to pass all the textframe to the previous position, when the textframe.geometricBounds [1] are not the left margin.

    }}

    trying to move all related texts frames which are not of the page.bounds [1] marginPreferences.left, after resizing the document.

    Thanks for help on this.

    Hello

    Try this to resize the last page of the doc. Do with the other pages if necessary.

    var
         targetPage = app.activeDocument.pages[-1];
         changedPageSize = [210,180];     // width, height
         currentPageSize = [
              targetPage.bounds[3] - targetPage.bounds[1],
              targetPage.bounds[2] - targetPage.bounds[0]
              ];
         wFactor = changedPageSize[0]/currentPageSize[0];
         hFactor = changedPageSize[1]/currentPageSize[1];
         mGroup = targetPage.groups.add( targetPage.allPageItems );
    
         targetPage.resize(
              CoordinateSpaces.INNER_COORDINATES,
              AnchorPoint.TOP_LEFT_ANCHOR,
              ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY,
              [wFactor, hFactor]);
         mGroup.resize(
              CoordinateSpaces.INNER_COORDINATES,
              AnchorPoint.TOP_LEFT_ANCHOR,
              ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY,
              [wFactor, hFactor]);
    

    Jarek

  • I can't use the tab key to move to the next field or use the shift and tab to move to the previous field in the forms.

    After update to 7.0.1 I can't always use the tab key to move to the next field or use the shift and tab key to move to the previous field in forms. He has always worked in previous versions and it is essential for my type of work. Does anyone know of a setting to enable this? If this is not the case, can the developers of Firefox is working on this issue (please). I love Firefox but desperately need this feature to work properly. Thank you!

    No - because it works in Mode safe mode, this means an extension is probably to blame. See http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes

  • How to move all the already marked spam emails for spam folder?

    Some emails are marked alread wich spam (there is an icon burn above), but still in my main Inbox folder. How to move all folder of spam at a time?

    Have you tried to select e-mails, drag and drop on the trash?
    Try to create a filter to move messages marked as spam to Spam folder.

  • Function to change all the form_specification in call_form

    Hi all

    I'll try to find a solution to change all the form_specification in call_form for an entire application, is possible to create a function or what... It is not effective to do by hand.


    Thank you!
    Micro

    THE: the arrest of is move my aplication of Win Linux server

    Published by: user10423661 on August 4, 2011 23:47

    If you don't have the appeal of the form in a procedure in a library?

    One way would be to update your code with JDAPI to substitute call_form instruction in all pl/sql in modules (and I'd do it for a procedure of Central Library).

    Steve

  • Sets a field in the subform and move all the fields?

    I am building a form and thought all I had to do was to "tweak" the location of some numeric fields and date to complete it.  These fields are floating in the text fields.  But when I move a field, all other fields move too.  When I press on the arrow to the left of the key fields still float to the right.  What is going on?

    My form of hierarchy is as follows:

    Form

    -> header as date fields, buttons, digital.  (this part of the form is ok)

    -> WorkHistory subform (content = Flowed, flow direction = up and down)

    -> Table2 (Binding = table repeat for each data item)

    -> tableheader

    -> tabledetail

    -> tablefooter

    -> PaymentInfo subform (content = positioned)

    -> digital text with "floating" fields and date fields.  This is the section, I have questions.  I am positioning the fields to appear as if it is part of the text fields.  All the numberic, text, date and lines, but not text fields, are moved when a field is moved.

    I am using lifecycle Designer ES2, version 9.0

    Thank you

    Mike

    Hi Mike,.

    Strange behavior, I think that because you have a positioned subform (Subform1) nested under a subform sank (WorkHistory).

    I've changed that while they were at the same level and the fields are moving without the fields next to them.

    https://Acrobat.com/#d=aWShNFztAAc-XgcG6f5urg

    Good luck

    Bruce

  • Cannot move all the files as windows explore crashes - it happens every time when you use an external hard drive (several readers have been tested and work on other machines)

    I need to move files on my laptop, but windows crashes Explorer everytime I try this. This also applies when you use an alternative program to explore. It didn't happen last week but regularly spent the last six months. It is now that I need to migrate these files (mainly the images, but also the music and office documents).

    The error in the Event Viewer log States the following: start the application failing application Explorer.EXE, version 6.0.6002.18005, time stamp 0x49e01da5, failed module unknown, version 0.0.0.0, time stamp 0x00000000, exception code 0xc0000005, offset 0x02db07e0, process id 0 x 1650 error, time 0x01ca547fd1de6851.

    Thank you

    Make sure that the device is compatible with Vista, the Vista Compatibility Center: http://www.microsoft.com/windows/compatibility/windows-vista/default.aspx.

    If you need to get pilots to leave the computer dealer or the manufacturer of the device (NOT of Microsoft Updates).  In fact, you must disable automatic updates in Windows Update driver as follows: http://www.addictivetips.com/windows-tips/how-to-disable-automatic-driver-installation-in-windows-vista/. Follow these steps: http://pcsupport.about.com/od/driverssupport/ht/driverdlmfgr.htm.  Once you have the drivers, you can install them via the Manager device as follows: http://www.vistax64.com/tutorials/193584-device-manager-install-driver.html.  You need to find the NAS device and the NICs in particular - but it would not hurt to look at all the when you're there.

    Go to start / Control Panel / Add Hardware and select the first option (recommended) to see if the system can detect the device.  If this does not work, choose the second and provide the information requested on the device.  You will be asked for drivers - have their practice.  Follow the prompts to install the device (NAS).  Make sure that it is plugged in and turned on when you do so, or he not be recognized.  It's the hard way of installing a hardware device, but your system obviously isn't automatically recognize it then do it manually. Here is a brief tutorial on how to do so: http://www.web-articles.info/e/a/title/Windows-Vista :-Running-the-Add-Hardware-Wizard /.

    I hope this helps.  Good luck! Lorien - a - MCSE/MCSA/network + / A +.

  • Move all the objects in the model without destroying keyframe positions?

    I built an animation based on a number of position keyframes.  I want to take the entire animation and just back up a bit on the screen so that it is centered better.  However, I don't know how to do this without manually set each keyframe for the move.

    I wish I could nest the whole comp within a clip and then change the position of this element.  Is there a way to do this in AE?

    3 ideas come to mind:

    1. Add a null value and parent all layers to null (if the layers have relatives, and then just parents parents of course). You can delete the null value later and change your keyframes for the new offset.

    2 pre compose all the layers and then move it as a single layer.

    3. If it's a 3D scene, then you can simply move the camera since it controls all the layers.

  • Can I move all the objects again selected layer without clicking hundreds of layer bars?

    I'm working on a complex illustrator file generated by GIS software. He gave me all kinds of groups of clip & road clip - what I really need, it's just to put all the same coloured polygons on the layer of a high level (unfortunately I can't draw all of my polygons in a group because illustrator doesn't pull these objects out of their existing clipping groups, and the card gets screwed completely upward if I release the clipping masks. With simple cards I have no problem Direct by selecting all of the polygons, I want, selecting their layers in the layers panel, then moving them to a new layer. This card is too complex, because there are hundreds of objects and hundreds of corresponding layers (they are not contiguous, or else I could simply click can be done with it).


    I used select > same > fill type to select all the polygons, I want that on a single layer, but I really hope that I don't have to select all the layers for each item one by one before I can move them to a new higher level layer. Does anyone know if there is a way to moving all the objects in a new layer selected without having to actually click all the layers in the Panel? Completely open to the alternative routes to my desired result!


    Thank you very much.

    Of course, after making the selection drag selection (to the right of the layer) icon on the desired layer. This will move any selected layer to the new layer.

  • move all the layers into a single layer

    Hello

    I am new to the script and I need to make a script that the passage of all the layers into one layer (in Illustrator I press CTRL + A and then CTRL + G in layers and works) but I need in the script

    Please could someone help me?

    Thank you!

    I found the solution

    main() {} function

    If (app.documents.length == 0) {return ;}

    app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

    var doc = app.activeDocument;

    var mast = doc.layers.add ();

    Mast.Name = "original";

    var group = mast.groupItems.add ();

    var pageIt = mast.pageItems.add ();

    While (doc.layers.length > 1)

    {

    While (doc.layers [doc.layers.length - 1].pageItems.length)

    doc. Layers [doc.layers.Length - 1] .pageItems [doc.layers [doc.layers.length - 1].pageItems.length - 1] .move (grup, ElementPlacement.PLACEATBEGINNING);

    doc. Layers [doc.layers.Length - 1] .remove ();

    }

    }

Maybe you are looking for