How to get the previous month and year accordingly

Hi friends,
I wanted to select the month as a number like 4 and the new year 2011
but I want to choose the previous month from sysdate
as if the sysdate is June 10, 2011
It should give me 5 months and
in the year, it should give as 2011
If the sysdate is January 1, 2012
the month should be like 12 and year should be in 2011

Thank you

Hello

776317 wrote:
Thank you very much I just the 0 being the prefix... can you pls how to avoid that too well pls

TO_CHAR ( ADD_MONTHS (SYSDATE, -1)
        , 'FMmm yyyy'
       )

For more information on the FM, wee manual SQL language modifier works:
http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/sql_elements004.htm#sthref456

Tags: Database

Similar Questions

  • How to get the Date, month, year of the DateTimePicker

    Hi, I am using the DateTimePicker.

    There are several question about this command:

    1. how to get the Date, month and year?

    -With the help of myDateTime.value, I get this string ' Wed May 08 14:45 ICT 2013 '-> I have to manually analyze this? Because I need in format yyyy/mm/dd. Or can set the format of dateTimePicker.value?

    2 format on dateTimePicker self (on the user interface) is d/m/YY, I can't change to another format?

    Thank you

    dateTimePicker.value return a QDateTime not a string.

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__datetimepicker.html#property-value

    See more:

    https://developer.BlackBerry.com/Cascades/reference/QDateTime.html#date

    https://developer.BlackBerry.com/Cascades/reference/QDate.html

    You can get

    day = dateTimePicker.value.date().day()
    month = dateTimePicker.value.date().month()
    year= dateTimePicker.value.date().year()
    dateYYYYMMDD = dateTimePicker.value.date().toString(Qt::ISODate)
    dateYYYYMMDD2 = dateTimePicker.value.date().toString("YYYY/MM/DD")
    dateYYYYMMDD3 = dateTimePicker.value.toString("YYYY/MM/DD")
    
  • I want to collect rain for the day, month and year; Can what formula I use?

    I want to collect rain for the day, month and year; What formula or expression that I can use.

    I use a Rain Wise product that converts impulses to an analog value.  The rain wise device can be

    "the value measure up to 1", 5", or 10".  I will be setting the unit at 10 inches in increments of 0.01 inch.

    What I would do is at each time increments of signal I would consider it as 0.01 then after reaching

    a period of time a day or a month, back to zero.

    Need some advice on this problem.

    How about you, using a counter to count the number of times where the signal is less than 0.01?

    For example,.

    Counter.Count = signal<=>

    The total number of rain is

    Counter * 10 + signal

    Use TimeOfDay or TimeOfWeek to reset the counter.

  • How to get the battery level and status in the cpp file?

    Hi all

    BatteryInfo class so I can I know how to get the battery level and the State in .cpp class?

    Hi Benecore,

    I have Add method below,

    #include

    But I only variable BatteryInfoPrivate not get variable BatteryInfo. You can also check on your side.

    So let me know how to get batteryInfo instance?

  • How to get the friend list and their IDS in the integration of Facebook using Facebook SDK

    can any body send me the code
    How to get the friend list and their IDS in the integration of Facebook using Facebook SDK
    I did after connection and wall

    Welcome on the support forums.

    Please check the strawberry sample that ships with the SDK

  • How to get the previous motnh

    Hi Experts,

    Can someone tell me to get the previos months beginning and end date...

    If m 20-dec-2012 then output should be 1 November 2012 and November 30, 2012...

    Thnx in advance...

    977490 wrote:
    Hi Experts,

    Can someone tell me to get the previos months beginning and end date...

    If m 20-dec-2012 then output should be 1 November 2012 and November 30, 2012...

    Thnx in advance...

    Use

    select trunc(trunc(sysdate,'MM')-1,'MM') "First Day of Last Month",
    trunc(sysdate,'MM')-1
    "Last Day of Last Month" from dual
    

    20-dec-2012

    Select TRUNC (trunc (to_date (20-dec-2012', 'mon-dd-yyyy'), "LUN")-1, 'MY')
    "First day of the month pr."
    trunc (to_date (20-dec-2012', 'mon-dd-yyyy'), "LUN")-1
    "Last day of the previous month.
    of the double

    Published by: Rahul India on January 24, 2013 14:37

  • How to get the outline color and size of the rectangle?

    Hi all

    I'm developing an extension for CS5 and higher (including the CC version). I want to get the outline color and size of a rectangle. I was able to do in CS5. But I noticed that in the version of the CC, there are two ways in which the user can apply to a stroke. One is by applying the effect in the layer Style, and the other through the properties panel. I am able to get the values of time in my script, if it is applied through layer Style, but I can't do it in the other scenario.

    How are these two different traits and how do I get the outline color and size if it is applied via the properties panel using script?

    Thank you!

    Here's what I have so far. It takes more work, but I don't think that's never very accurate.

    function toggleOtherLayersVisibility() {
        var desc = new ActionDescriptor();
            var list = new ActionList();
                var ref = new ActionReference();
                ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
            list.putReference( ref );
        desc.putList( charIDToTypeID('null'), list );
        desc.putBoolean( charIDToTypeID('TglO'), true );
        executeAction( charIDToTypeID('Shw '), desc, DialogModes.NO );
    };
    function liveShapeFillEnabled( enable ) {// boolean
        var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putEnumerated( stringIDToTypeID('contentLayer'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
        desc.putReference( charIDToTypeID('null'), ref );
            var shapeDesc = new ActionDescriptor();
                var styleDesc = new ActionDescriptor();
                styleDesc.putInteger( stringIDToTypeID('strokeStyleVersion'), 2 );
                styleDesc.putBoolean( stringIDToTypeID('fillEnabled'), enable );
            shapeDesc.putObject( stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), styleDesc );
        desc.putObject( charIDToTypeID('T   '), stringIDToTypeID('shapeStyle'), shapeDesc );
        executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
    };
    function dupeVisibleMerged() {
        var desc = new ActionDescriptor();
        desc.putBoolean( charIDToTypeID('Dplc'), true );
        executeAction( charIDToTypeID('MrgV'), desc, DialogModes.NO );
    };
    function loadTransparency(){
        var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
        desc.putReference( charIDToTypeID( "null" ), ref );
            var ref1 = new ActionReference();
            ref1.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Trsp" ) );
        desc.putReference( charIDToTypeID( "T   " ), ref1 );
        executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
    };
    function getLiveShapeStrokeInfo(){
        var doc = app.activeDocument;
        var lyr = doc.activeLayer;
        liveShapeFillEnabled( false );
        toggleOtherLayersVisibility();
        doc.artLayers.add();
        dupeVisibleMerged();
        var bounds = doc.activeLayer.bounds;
        var horzCenter = (bounds[2]-bounds[0])/2;
        var vertCenter = (bounds[3]-bounds[1])/2;
        lyr.visible = false;
        var sampler = doc.colorSamplers.add([bounds[0]+UnitValue(.5,'px'),bounds[1]+vertCenter]);
        sizeObject.color = sampler.color;
        loadTransparency();
        doc.selection.select([
                                [bounds[0],bounds[1]+vertCenter],
                                [bounds[0]+horzCenter,bounds[1]+vertCenter],
                                 [bounds[0]+horzCenter,bounds[1]+vertCenter+UnitValue(1,'px')],
                                 [bounds[0]+UnitValue(1,'px'),bounds[1]+vertCenter+UnitValue(1,'px')]],SelectionType.INTERSECT);
    
        sizeObject.size = doc.selection.bounds[2]-doc.selection.bounds[0];
    };
    var sizeObject = {};
    app.activeDocument.suspendHistory('Get Live stroke info','getLiveShapeStrokeInfo()');
    executeAction( charIDToTypeID('undo'), undefined, DialogModes.NO );
    sizeObject.size;
    
  • How to get the files to and from the host

    Is there something that I can read which explains how to get the (ftp, memory stick or other) files to and from the host?

    Sorry if this is a noob question, I looked but could not find something specific...

    There are many ways of doing so:

    1 activate not supported ssh and scp use

    2. use VI Client access to your storage space on configuration files and server transfer

    3 configure the iSCSI or NAS to deal directly

  • How to get the name constraintlist and column in a table?

    Hello


    can someone please tell me how to get the type of constraint, and it is imposed on the names of columns in a table.




    Thank you
    Nico

    Hello

    Use the two tables:

    select * from all_constraints
    
    select * from ALL_CONS_COLUMNS
    

    Sorry SY, you were faster than me...

    Published by: user11268895 on August 19, 2010 13:27

  • [MAF] How to get the user name and password after login?

    Hi Experts,

    I have a call to REST where it requires identification information of the user (uname and password) to identify the data that belongs to who.

    Authentication has been made with OAuth.

    I believe that there is an API to get the user name and password in the CRG

    See you soon,.

    Hendry

    Hello.

    You don't need to manipulate the credentials yourself in code. MAF will propagate the logon cookie or inject the identification information in the HTTP header if cookies are not supported.

    To do this, you must select the purchase option of cookie from the server connection Include in REST in the dialog box create a connection Login MAF , such as discussed here:

    http://docs.Oracle.com/middleware/maf210/mobile/develop/MAF-securing.htm#ADFMF23732

    In addition, you must attach the policy of security appropriate to the connection, as explained here:

    http://docs.Oracle.com/middleware/maf210/mobile/develop/MAF-Web-services.htm#ADFMF23697

    Best regards

    Frédéric Desbiens

    Senior Product Manager

    Mobility and Cloud oracle

    Twitter: @BlueberryCoder

    blog: http://blogs.oracle.com/blueberry

  • recovery of the previous months and the months to come

    Hello

    I need a list of the last months of the current year as well as a list of the coming months + during the current year.

    Example:
    Today is September 5, 2012.

    Then I nead a list of previous months:

    January
    February
    March
    April
    May
    June
    July
    August


    And al ist of the coming months, including the current month:
    September
    October
    November
    December

    How can I achieve this.
    I know it takes with connect by, but have little experience and knowledge of this.
    I'll have to acquire some knowledge on this subject.

    Thank you
    Diana
    SQL> select  to_char(to_date(level,'mm'),'FMMonth') month
      2    from  dual
      3    connect by level < to_number(to_char(sysdate,'mm'))
      4  /
    
    MONTH
    ---------
    January
    February
    March
    April
    May
    June
    July
    August
    
    8 rows selected.
    
    SQL> select  to_char(add_months(sysdate,level - 1),'FMMonth') month
      2    from  dual
      3    connect by to_number(to_char(add_months(sysdate,level - 1),'mm')) != 1
      4  /
    
    MONTH
    ---------
    September
    October
    November
    December
    
    SQL> 
    

    SY.

  • Calculate the age (months and years) of two dates

    Trying to get the (almost exact) age in years and months to fill in 'Age at the time of retirement' (years1) since the date of birth (DOB1) and the date of their departure in retirement (retireDate1). The only examples that I could find are dates "today." If anyone can help with code? And I understand it works better with JavaScript but FormCalc would also work?

    Dates as DD/MM/YYYY

    Field is num {z9}

    Thank you in advance for your help!

    I could do this work with Age1 as a text field. Of course, you can do whatever you want with it, but this method makes the most sense for me because I can say 99 months "99 years". If you need to separate the year and month in different areas, you should be able to do it easily. Finally, it requires that the user does not manually enter dates. (Something on the raw values isn't quite right when they came from the selection.)

    Age1::calculate (or anywhere where you want this event)

    if (!DOB1.isNull && !retireDate1.isNull){
      var d1 = DOB1.rawValue.split('-');
      var d2 = retireDate1.rawValue.split('-');
      var years = parseInt(d2[0]) - parseInt(d1[0]);
      var months = (parseInt(d2[1]) - parseInt(d1[1]));
      if (parseInt(months) < 0){
        months = 12 + months;
        years--;
      }
      Age1.rawValue = years + " years " + months + " months.";
    }
    
  • How to get the previous record that meets a criterion?

    Hello!

    I am trying to create a query that adds information which finally fixed an element for a given 'pause'.

    I have a table, let's call it actionHistory, which looks like:

    ID | timestamp | action | author
    ------------------------------------------------
    101477 | 2010-05-10 09:10:20 | Difficulty | Tim
    101477 | 2010-05-10 09:10:30 | change | John
    101477 | 2010-05-10 09:10:40 | breaking | Maggie
    101477 | 2010-05-10 09:10:50 | Difficulty | Rick
    222222 | 2010-05-10 09:10:30 | change | Lewis
    222222 | 2010-05-11 09:10:40 | breaking | Maggie
    222222 | 2010-05-11 09:10:50 | Difficulty | Tim
    222222 | 2010-05-12 09:10:40 | Difficulty | Maggie
    222222 | 2010-05-13 09:10:40 | breaking | Albert

    I'm looking for is the following result:

    ID | timestamp | action | author | lastFixBy
    -----------------------------------------------------------
    101477 | 2010-05-10 09:10:20 | Difficulty | Tim |
    101477 | 2010-05-10 09:10:30 | change | John |
    101477 | 2010-05-10 09:10:40 | breaking | Maggie | Tim
    101477 | 2010-05-10 09:10:50 | Difficulty | Rick |
    222222 | 2010-05-10 09:10:30 | change | Lewis |
    222222 | 2010-05-11 09:10:40 | breaking | Maggie |
    222222 | 2010-05-11 09:10:50 | Difficulty | Tim |
    222222 | 2010-05-12 09:10:40 | Difficulty | Maggie |
    222222 | 2010-05-13 09:10:40 | breaking | Albert | Maggie

    Can you tell me how I can make?
    I tried many ways but no return to what I'm looking for.

    Thanks in advance.

    Published by: user8910765 on June 5, 2010 13:51

    Published by: user8910765 on June 5, 2010 14:00

    Hello

    That's what you asked for in Oracle 10:

    SELECT       a.*
    ,       CASE
               WHEN  action = 'break'
               THEN  LAST_VALUE ( CASE
                                    WHEN  action = 'fix'
                                    THEN  author
                                   END
                                   IGNORE NULLS
                               ) OVER ( PARTITION BY  id
                                               ORDER BY      tmstmp
                                    )
           END        AS lastfixby
    FROM       actionhistory         a
    ORDER BY  id
    ,            tmstmp
    ;
    

    Like all of the built-in functions, LAST_VALUE is documented in the manual of the SQL language:
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions073.htm#sthref1508

    user8910765 wrote:
    ... just in case where it might be useful, one of the queries I've tried myself a left subquery joined that Oracle has no right ("a column may be outside not attached to a subquery').

    Much more, it would help if you posted the request.
    It looks like you were using the old outer join notation (+). You can get the desired results by using an outer join with ANSI rating, but I think it would be more complicated and slower than with a LAST_VALUE.

  • How to get the menu bar and dock to stay visible in Mail?

    To expand the text in my mail, I hit full screen to see if the text to expand.  However, I lost the menu bar and the dock, which was still visible before.  I have a Mac Pro with the retina (13 '').  If I move the cursor to the top or the bottom of the screen, they show.  I read that if I press ESC, it will leave full screen.  Well, it does, but the screen is reduced to half of its size and the menu comes on top.  But how I show all the time in the mail.  Weather in Safari.  Thank you!  Debbie

    Exit full screen. Hold the option key and press the green button to expand the format full screen or

    You can drag the window of mail to any size you want from the corner or edge.

  • How to get the active directory and environment variables

    Hello

    1 - is there a global variable to get the real (project, where is ORD and DSQ files) directory?

    2.-y there a way to get the directory of the user as the reading of the operating system environment variables?

    Thanks in advance.

    PD: I use Dasylab12

    Yes, use ropes of system

    For example, ${DATA_FOLDER}.

    For a list, the simplest method is to right click and select global chains. The lower half of the dialog box lists the system strings, including the date, time, name of the worksheet, with or without a path, the DEFAULT folders for the spreadsheet, data, other, black box, etc.

Maybe you are looking for