How to get the last day of the previous month

Hello Team,
If  my input date is today , then i need to find out the last day of the previous month for the same.
Can someone help me  to find out .. how can this be done.
Regards,
Ravi

Hi,
Try the below code.
     // get a calendar object
    GregorianCalendar calendar = new GregorianCalendar();
    // convert the year and month to integers
    int yearInt = Integer.parseInt(year);
    int monthInt = Integer.parseInt(month);
     int dayInt = Integer.parseInt(day);
    // adjust the month for a zero based index
    monthInt = monthInt - 1;
    // set the date of the calendar to the date provided
    calendar.set(yearInt, monthInt, dayInt);
    int day = calendar.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
    return Integer.toString(day);
Regards
Venkat

Similar Messages

  • How to get the previous month and year accordingly

    Hi friends,
    I wanted to select month as number like 4 and year as 2011
    but I want to select the previous month as of sysdate
    like if the sysdate is 10-jun-2011
    it should give me 5 as month and
    in the year it should give as 2011
    if the sysdate is 01-jan-2012
    the month should be as 12 and year should be as 2011
    thanks

    Hi,
    776317 wrote:
    thanks a lot I just dont need the 0 being prefixed... can you pls tell how to avoid that as well pls
    TO_CHAR ( ADD_MONTHS (SYSDATE, -1)
            , 'FMmm yyyy'
           )For details about how the FM modifier works, wee the SQL Language manual:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements004.htm#sthref456

  • How to get the current month number

    Hi everyone,
    Does anybody know how to get the current month number in Oracle Discoverer Worksheet calculation?
    I try to use EUL_DATE_TRUNC(CURRENT_DATE, 'MM'), but instead I got 01-AUG-00.
    If I change the data display format to MM, it will give me "08" but if I use TO_NUMBER function to convert it to number I get error "invalid number"
    Is there anyway to get the current month value in number? Thanks

    Scott,
    Thank you so much! It works perfectly! :)
    Hope you have a great day ahead!
    Cheers,
    Angeline

  • How to Get the current month at timezone UTC-10

    Hi All,
       can you please let me know How to Get the current month at timezone UTC-10.
    Function module ? which date and time needs to pass.

    Hi,
    Try with following code.
    DATA zdate TYPE  D.
    DATA ztime TYPE  T.
                      CALL FUNCTION 'ISU_DATE_TIME_CONVERT_TIMEZONE'
                        EXPORTING
                          x_date_utc          = sy-datum
                          x_time_utc          = sy-uzeit
                          x_timezone          = 'UTC-10'
                       IMPORTING
                         Y_DATE_LCL          = zdate
                         Y_TIME_LCL          = ztime
                       EXCEPTIONS
                         GENERAL_FAULT       = 1
                         OTHERS              = 2.
                      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 : zdate, / ztime.
    Thank you,
    Sekhar.

  • How to get the current month value for a customer exit variable?

    How to get the current month value for a customer exit variable? 
    And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
    Thanks!

    Hi Kevin,
    Check here........
    Re: Customer Exist for "From Current Date To Month End"
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
    Cal month
    Regards,
    Vijay.

  • How to get the previous state of my data after issuing coomit method

    How to get the previous state of some date after issuing commit method in entity bean (It should not use any offline storage )

    >
    Is there any way to get the state apart from using
    offline storage ?As I said the caller keeps a copy in memory.
    Naturally if it is no longer in memory then that is a problem.
    >
    and also what do you mean by auditlog?
    You keep track of every change to the database by keeping the old data. There are three ways:
    1. Each table has a version number/delete flag for each record. A record is never updated nor deleted. Instead a new record is created with a new version number and with the new data.
    2. Each table has a duplicate table which has all of the same columns. When the first table is modified the old data is moved to the duplicate table.
    3. A single table is used which has columns for 'table', 'field', 'data' and 'activity' (update, delete). When a change is made in any table then this table is updated. This is generally of limited useability due to the difficulty in recovering the data.
    All of the above can have a user id, timestamp, and/or additional information which is relevant to the data being changed.
    Note that ALL of this is persisted storage.
    I am not sure what this really has to do with "offline storage" unless you are using that term to refer to backed up data which is not readily available.

  • How to get the previous record value in the current record plz help me...

    In my sql how to get the previous record value...
    in table i m having the field called Date i want find the difference b/w 2nd record date value with first record date... plz any one help me to know this i m waiting for ur reply....
    Thanx in Advance
    with regards
    kotresh

    First of this not hte mysql or database forum so don;t repeate again.
    to get diff between two date in mysql use date_format() to convert them to date if they r not date type
    then use - (minus)to get diff.

  • How to get Last Day of a Previous Month

    Hi all,
    I need to get Last Day of the Previous Month. I am able to get Current Month Last Day using Calendar.getActualMaximum(Calendar.DATE)
    But I need previous Month's Last Day.
    Thanks
    Vamshi.

    Thanks all....
    I have been trying the same and could get it.....
    here is the code for that....
    SimpleDateFormat simpleDate = new SimpleDateFormat("MM/dd/yyyy");
    Calendar calendar = Calendar.getInstance();
    month = calendar.get(Calendar.MONTH);
    //year = calendar.get(Calendar.YEAR);
    calendar.set(Calendar.MONTH, month-1);
    calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
    //lastDayOfMonth = calendar.getActualMaximum(Calendar.DATE);
    System.out.Println("Previous Month End Date is :: " + simpleDate.format(calendar.getTime()));
    this works....
    thanks for ur replys....

  • How to get the count monthly wise

    Hi All
    I have lot of order dispatched in a year 2010, how to get the moth wise total.
    For example jan 1000 orders ,feb 2500 orders.
    Thanks & Regards
    Srikkanth.M

    Pleiadian wrote:
    Maybe even
    b.schedule_ship_date between to_date('2010','YYYY') and to_date('2011','YYYY');)But this could return schedule ship dates that are 01-Jan-2011 00:00:00. I don't think this is wanted since it was not specified in the original requirement. I'm not even sure if to_date('2010','YYYY') returns 01. Feb.2010 in a few days (when we will have february).
    Just checking the docs....
    found it: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#SQLRF51062
    from the docs:
    If you specify a date value without a time component, then the default time is midnight (00:00:00 or 12:00:00 for 24-hour and 12-hour clock time, respectively). If you specify a date value without a date, then the default date is the first day of the current month.Just to be on the safe side always give the complete format mask!
    b.schedule_ship_date >= to_date('01012010','DDMMYYYY')
    and b.schedule_ship_date < to_date('01012011','DDMMYYYY')Edited by: Sven W. on Jan 17, 2011 5:14 PM

  • How to get the currrent month and year from a new date object

    If I create a new Date object as "d",
    java.util.Date d = new java.util.Date();how can I format the date to get the current Month as 'Jan' and the current year as '2008'. So if I have something like d.getMonth() gets the current month as 'Oct' and d.getYear() gets '2008'
    Thanks,
    Zub

    [Read the flamin' manual you must. Hmm.|http://en.wikipedia.org/wiki/RTFM]
    ~~ Yoda.
    Well no actually, he didn't say that, but he should have.
    Cheers. Keith.
    PS: Don't say that to a 7 foot pissedOff wookie when he's got his head stuck in a smoking hyperdrive, and you're being chased by a S-class battle cruiser... Ask Yoda how he got to be so short.
    PPS: It is the SimpleDateFormat you seek ;-)
    Edited by: corlettk on 14/10/2008 22:37 ~~ Also far to slow... but funny.

  • How to get the current month for a variable based on info object 0FISCPER3

    Hie Gurus
    I am working on the financial reports i am failing to derive the Current month from the variable based on infobject 0FISCPER3 PERIOD .
    I would also like to get the same month from the prevoius year. Any ideas?

    If I understood correctly, you need in your repot
    Current Month Plan This year || YTD Plan This Year || Current Month Plan Last Year || YTD Plan Last Year
    Your variable 0I_FISCPER3 must be on the object 0FISCPER3 which is nothing but just the Fiscal Period. This variable is a user entry mandatory Interval variable.
    if you are entering a range in the input screen for this variable, you will get cumulative values. If you just need to get the value for a month in first column your report, you will have to create another variable of type Customer Exit which will read the "To value" entered for the variable 0I_FISCPER3 and columns for Current Month should be restricted on this variable.
    if you are entering a single value in the selection screen of this variable, current month column should be restricted on this variable with "Equal To" operation and YTD colmns should be restricted to "Less Than Equal to" operator with this variable.
    0FISCPER3 just have posting period and not year, so you will have to use varialbes for 0FISCYEAR separately.
    Please let us know if it helps or if you are using some other variable based on 0FISCPER3 or 0FISCPER.
    Regards,
    Gaurav

  • How to get the previous version of Flash professional?

    I need to install flash proffessional on 32 bit computer? How can I get the previous version as the Flash ProfessionalCC requires 64 bit?
    Many thanks for help.

    Hi Barbara,
    Flash Professional CS5.5 is a 32-bit application which can be installed on computers with either 32-bit or 64-bit operating systems.
    You can purchase this by Adobe's backward Licensing policy :
    " Adobe allows program members to order a current-version license but use a prior version. These members can contact Adobe Customer Service to request a serial number for the earlier version if they do not already have one. Prior-version software is available via ESD and can be purchased through standard resellers. The program member must follow all guidelines of the current-version EULA. "
    Please check the doc : http://www.adobe.com/volume-licensing/policies.html

  • How to get the first month of the year inputed by user manually

    Hi Expert,
    Just like the subject, I 'd like to get the first month of the year inputed by user manually, but don't know how to set the variable, please help.
    For example, user execute a query and input the value of variable Year = 2010, and what I want to get is 201001 into another variable, so that I can use this variable to setup another selection.
    Thank you.
    Andy

    Hi Andy,
    1) U will create a user input varaible for year and say it is ZYEAR.
    2)  U will create another variable  for calmonth  which has processing type : customer exit ..single value ...mandatory ....say ZCMONTH.
    This needs to be populated using the year( user inputted )  and calmonth '001'
    This code will fetch the user input value into ZYEAR and append '001' to the user input value and the value
    will be passed to the ZCMONTH varaible...
    Sample Code is....
    When 'ZCMONTH'.
    IF I_STEP = 2.
         READ TABLE I_T_VAR_RANGE WITH KEY VNAM = 'ZYEAR'.
         IF SY_SUBRC = 0.
                    L_S_RANGE-LOW  =  I_T_VAR_RANGE-LOW.
                   L_S_RANGE-LOW+4(3) = '001'.
                  L_S_RANGE-SIGN = 'I'.
                 L_S_RANGE-OPT  = 'EQ'.
                      APPEND L_S_RANGE TO E_T_RANGE.
        ENDIF.
    ENDIF.
    Regards
    vamsi

  • How to get the previous price of the  list price  in a order

    Hi All,
    I need to get the previous price of the condition type in an order  to calculate the %change of price.
    for ex: the conditon ZXXX has price 600 and its changed to 400 now .( by changing the quantity etc ).
    when the price value is changing to 400 , I need to capture  the value of 600 in another condition type.
    how can i acheive this ? Any idea?
    Please provide some pointers on it.
    Thanks in advance.
    Swapna.

    Hi Viraylab,
                     check  <b>VBAP-NETPR</b> field of table <b>VBAP</b>
    It gives the net price corresponding to a line item.
    Goto Tcode VA03.See the <b>item overview</b> tab U will get <b>Net Price</b> field for indivisual line item.
    Reward points if helpful.
    Regards,
    Hemant

  • [CLOSED] How to get the previous day of a day

    Hi all,
    How do I minus a day from another day?
    For example
    Table1
    Code Meaning
    1 'Monday'
    2 'Tuesday'
    The result for the below query should be 'Monday'
    select PreviousDayOf(Table1.Meaning)
    from SomeTable, Table1
    where SomeTable.Code = Table1.Code
    and Table1.code = 2
    Thank you for your time.
    Message was edited by:
    user594688

    You could do a double DECODE. It may not be the best approach in the world but it may suit your needs.
    Here is a sample:
    SQL> CREATE TABLE table1(code number, meaning varchar2(15));
    Table created.
    SQL> INSERT INTO table1(code,meaning) VALUES (1,'Monday');
    1 row created.
    SQL> INSERT INTO table1(code,meaning) VALUES (2,'Tuesday');
    1 row created.
    SQL> SELECT * FROM table1;
          CODE MEANING                                                             
             1 Monday                                                              
             2 Tuesday                                                             
    SQL> SELECT DECODE(DECODE(meaning,'Monday',1,'Tuesday',2)-1,1,'Monday',2,'Tuesday') FROM table1 WHERE code=2;
    DECODE(                                                                        
    Monday                                                                         
    SQL> spool off;Hope this helps!

  • How to get the previous Day of a specified day?

    Hi
    Iam developing a report and I want it to show the data of the previous day
    What is the query required to do that?
    Note:
    there is a field to insert the date for data saving

    You also need to be careful about the time part of the date, e.g.
    SELECT   TO_CHAR(SYSDATE,'DD/MM/YYYY HH24:MI:SS')
    ,        TO_CHAR(SYSDATE-1,'DD/MM/YYYY HH24:MI:SS')
    FROM     dual;
    TO_CHAR(SYSDATE,'DD TO_CHAR(SYSDATE-1,'
    06/12/2008 11:57:49 05/12/2008 11:57:49
    1 row selected.You can use the TRUNC command to strip the time from the date:
    SELECT   TO_CHAR(TRUNC(SYSDATE),'DD/MM/YYYY HH24:MI:SS')
    ,        TO_CHAR(TRUNC(SYSDATE)-1,'DD/MM/YYYY HH24:MI:SS')
    FROM     dual;
    TO_CHAR(TRUNC(SYSDA TO_CHAR(TRUNC(SYSDA
    06/12/2008 00:00:00 05/12/2008 00:00:00
    1 row selected.

Maybe you are looking for

  • Issue with Customize program for Dunning Forms

    Hi  Experts I have write a perform for dunning form in a outside report apart from standard print program. After doing some calculations I want print some information in the form using the function module "Write_Form", but I am not able write on the

  • Upgraded from Aperture 2 to 3 and now photos are no longer in photo book

    Hi, I've recently upgraded my copy of Aperture from version 2 to 3 and after my library had updated everything seemed fine until I looked at a photo book I was working on. It appears that all of the photos that I had placed in the book are no longer

  • How much truth in email solliciting about 'VIRUS' threats?

    I keep receiving email from a company that tells me: "...Macs don't get viruses. THINK AGAIN!..."..trying to sell me a 'Virus Barrier'. I have searched all info I could find on virusses (viri??) on these forums, and came up zero on real threats. As f

  • TS2537 Mac OS X v10.7.3 latest version. Can't use Mail

    I'm having the same problem with Mail but with the latest Lion version (OS X v.10.7.3). Can't quit Mail, can't read messages, can't shut down. I just moved to an Apple computer with the hope to live in the "promise land" of no more crashes. Never hap

  • Error creating a procedure

    I'm trying to create a procedure where I pass in a cursor. I'm on Oracle 9i and SQL is not my main job, though I do a good bit of complex querying and reading SQL. The code below is simplified, but I am still receiving an error "PLS-00201: identifier