Getting last date of the previous  month

Hi
   Am giving one date. FOr that day i hav to take previous month last date.
How can i do. IMportant : Last date of previous month

u can make the code work like this.
data: date like sy-datum,
      date1 like sy-datum.
date = sy-datum.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
  EXPORTING
    day_in                  = date
IMPORTING
   LAST_DAY_OF_MONTH       = date1
EXCEPTIONS
   DAY_IN_NO_DATE          = 1
   OTHERS                  = 2
add 1 to date1.
write:/ 'next month start date:', date1.
*to fetch the march month last date.
date1+4(2) = 03.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
  EXPORTING
    day_in                  = date1
IMPORTING
   LAST_DAY_OF_MONTH       = date1
EXCEPTIONS
   DAY_IN_NO_DATE          = 1
   OTHERS                  = 2
write:/ 'last date of march:', date1.
Please close your previous threads.

Similar Messages

  • Get last date of the current month

    Hi all,
       Is there any FM used to get the last date of
    sy-datum.
    Regards,
    bala

    check..
    RE_LAST_DAY_OF_MONTH
    SG_PS_GET_LAST_DAY_OF_MONTH
    parameters: p_fdate like sy-datum.
    DATA: M_DATE LIKE SY-DATUM,
    CALL FUNCTION 'LAST_DAY_OF_MONTHS' "#EC EXISTS
    EXPORTING
    DAY_IN = P_FDATE
    IMPORTING
    LAST_DAY_OF_MONTH = M_DATE.
    case mdate+3(2).
    when 30.
    write: '30 days'.
    when 28.
    write: '28 days'.
    when 29.
    write: '29 days'.
    when 31.
    write: '31 days'.
    endcase.

  • 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....

  • FM for the last date of the previos month

    Hi folks
    my requirement is if we enter the calendar month say YYYYMM in the selection
    screen. it has to get the previous month last date in the format DDMMYYYY
    For eg.,  selection screen input  200704
                required output : 31/03/2007
    Is there any standard function module.
    please urgent
    Thanks in Advance
    Rao

    Hi,
    Please try this.
    data: wa_idate like sy-datum,
          wa_odate like sy-datum.
    wa_idate(6) = p_date.
    wa_idate+6(2) = '01'.
    wa_odate = w_idate - 1.
    OR
    call function 'RP_CALC_DATE_IN_INTERVAL'
      exporting
        date      = wa_idate
        days      = 0
        months    = 1
        signum    = '-'
        years     = 0
      importing
        calc_date = wa_odate.
    write: / 'Last date of the previous month: ', wa_odate.
    Regards,
    Ferry Lianto

  • 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

  • Getting data in a query on last date of all previous months

    Dear Experts,
    I need your help with a query.
    I am trying to create a query which when run should pick the number of Open Sales Order on the last date of all the previous months from the start of company.
    I could create the query for fetching the required data on last day of the previous month, say today is 25th June 2014, so my query only fetches data for May 31st 2014 but I need data for all previous month, May 31st 2014, April 30th 2014, March 31st 2014 & so on.
    Please advise how to achieve this is SQL query.
    Thanks & regards,
    Nitin

    Hi,
    Try this:
    Select *
    from(
    SELECT T0.[DocNum] as #,t0.cardcode as C, t0.docdate
    FROM ORDR T0
    WHERE T0.[DocStatus] = 'o' and T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-1,0)),10) OR T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-2,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-3,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-4,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-5,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-6,0)),10) or T0.[DocDate]  = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-7,0)),10)
    group by t0.cardcode,docdate,T0.[DocNum]) S
    pivot
    (count(#) for c in([cvt01],[cvt02],[cvt03],[cvt04],[cvt05],[cvt06],[cvt07],[cvt08],[cvt12])) P
    Note: Replace Cvt01,02...with your customer code.
    Thanks & Regards,
    Nagarajan

  • Function module to get the same date of the previous month

    Hi
    Can anybody tell me how to get the
    same date of the previous month.
    example if i am entering date as 30 may 2007
    i want the date as 30 april 2007

    CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
    date = pa_end
    days = '00'
    months = '01'
    signum = '-'
    years = '00'
    IMPORTING
    calc_date = pa_end.
    ENDIF.
    nd try below FMs as well...
    CCM_GO_BACK_MONTHS
    HR_PT_ADD_MONTH_TO_DATE
    RP_CALC_DATE_IN_INTERVAL
    Hope it will solve your problem...
    Reward points if useful..
    Thanks & Regards
    ilesh 24x7

  • Is there a way to show the end dates of the previous month stand out?

    is there a way to show the end dates of the previous month in bold or make it stand out? so 30,31 and 1st of this month don't all look the same? For example the 30,31st get a regular text since they are a part of the the last month and this month gets bold dates? Its hard to read the dates anyways.

    Pics and more
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.
    5:05 PM Sunday; January 4, 2009

  • 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

  • Last Date of the next month

    Hi,
    How to find the last date of the next month.
    Thanks in advance
    Sunitha

    Use the below mentioned FM
      call function 'LAST_DAY_IN_PERIOD_GET'
        exporting
          i_gjahr              = p_finyear
          i_periv              = 'X1'
          i_poper              = lv_popere
        importing
          e_date               = p_edate
        exceptions
          input_false          = 1
          t009_notfound        = 2
          t009b_notfound       = 3
          others               = 4.
      if sy-subrc <> 0.
      endif.
    Supply the proper parameters, u will get the last date in  the next month.

  • Last date of the previous quarter

    Hi,
    How can i find the last date of the previous quarter, based on todays date (the fiscal year starting from 1st April)
    the quarters are 1st april to 30th June, 1st July to 30th sept, 1st Oct to 31st Dec and 1st Jan to 31st March

    872435 wrote:
    Hi,
    How can i find the last date of the previous quarter, based on todays date (the fiscal year starting from 1st April)
    the quarters are 1st april to 30th June, 1st July to 30th sept, 1st Oct to 31st Dec and 1st Jan to 31st MarchTry this function:
    select add_months(add_months(trunc(sysdate,'Q'),-1) - 1,1) from dual;
    Ion

  • How to get last date of the week

    hi,
    how to get last date of the week like FM WEEK_GET_FIRST_DAY gives the date of the first day of the week i need the date of the last day of the week..
    thnx

    data : p_week type KWEEK,
    p_Date type SYDATUM.
    p_week = <incoming value in week of year>
    CALL FUNCTION 'WEEK_GET_FIRST_DAY'
    EXPORTING
    week = p_week
    IMPORTING
    DATE = p_date
    EXCEPTIONS
    WEEK_INVALID = 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.
    To get the last day of the week.
    p_date = p_date + 6.
    You can find the available fm in the system from se37 transaction code.

  • Filter a List for data from the Previous Month

    Hello,
    I have audit data for each month of the year.  At the beginning of one month I pull a report from the previous month.  I would like to have a view in my SharePoint list that shows only the data from the previous month.
    I am not a programmer or developer, so I was wondering if this is possible without out of the box tools.
    Here is what I have done so far:
    Created two calculated columns to find the start and end date of the previous month
              Previous Month Start =DATE(YEAR([Date of Review]),MONTH([Date of Review])-1,1)
              Previous Month End   =DATE(YEAR([Date of Review]),MONTH([Date of Review]),0)
    I have verified these two calculations do show the correct dates. 
    So I can generate the dates, but I don't know how to set up a view filter that will show only data from the previous month. 
    Please help.

    What you need is the calculated column to display the start and the end of the next month, not the previous month. Then you can do a view filter where Start<Today & End>Today.
    EX: If you have a document with date 15-03-2014, you need to save the dates 01-04-2014(start) and 30-04-2014(End).
    Then If Start < [Today] and End > [Today], you can show the document

  • Call object was called with start date in the previous month

    We have a single cycle maintenance plan for 30 days.
    Shift Factor Late Compl.   : 100%
    Tolerance                    :  10%
    Shift Factor Early Compl. :  100%
    Tolerance                    :    10%
    Cycle modification factor:    1
    Factory calendar            :  NIL
    Call horizon                    : 100%
    Scheduling period          :  90 DAY
    Scheduling indicator       : Time
    Call no . 11 was a plan date of 14.08.2009 has completion date 14.08.2009. Schedule type/status has "scheduled complete".
    Call no. 12 was called on 13.09.2009 which is in the past.
    Can someone explain why the system called the order with a starting date in the previuos month , that is , 13.09.2009.
    And how to rectify it to make it current date for the next call object?
    Thanks,
    Manohar

    I checked the algorithm for call no. 12
    Start of Cycle                07.08.2008
    Last planned date         14.08.2009
    Compl.Predecess           14.08.2009        Absolute shift                +   0 Da
    Planned cycle/offset      +    30 Da          Relative shift            0 % =   0 Da
    Shift                                 +     0 Da           erance value           0 % =   0 Da
    Planned Dates Due   13.09.2009    Completed on
    Last call on              15.10.2009    Called by               IP1020091015
    Workorder generated has start date 13.09.2009.
    Should we restart this plan , as the start dates in call object are at least 1 month old ?
    Thanks,
    Manohar

  • How to get  --Last date of the Last value .

    Dear All,
    I have a report like
    Material – Country – Current Price
    1112-----  Singapore  -
      100
    1112-----  Japan  -
      120
    1112-----  Malesia   -
      99
    Here current price is Last Value of the particular Material on particular Date.
    This I can get based on Key figure Aggregation ( Last Value and reference Character 0CALDAY ), It is giving the last Value of the Particular Material.
    Now my user wants to see Last date of the value ( Date of the Value )
    Example :-
    Material – Country –  Date --Current Price
    1112-----  Singapore  -
    01/04/2008 -- 100
    1112-----  Japan  -
    04/05/2008 -- 120
    1112-----  Malesia   -
    05/05/2008 -- 99
    If  I drill down the date in my  report  it is showing all dates , my user wants to see only last date .
    Hope some one has solved this issue , please help me to solve this issue.
    Regards,
    SHAIK.

    I have created a keyfigure with date as a data type.
    In aggregation tab, I selected  aggregation Maximum.
    Upto DSO, data is Loaded perfect. Ok.
    I added the same key figure in cube , When I am trying to Activate the Transformation,
    It is giving Error message.
    Rule 17 is invalid and is being deleted. The reason for this is that a field or InfoObject that is used in rule 17 has been deleted in the source or target of the transformation ODSO ZPL_DSO1 -> CUBE ZPLATT_C (0GH6MHANQ2J79LXZBLGIJ9ZK9LWHK6RS)
    Plz Advice.
    Regards,
    SHAIK
    Edited by: shaik on May 7, 2008 5:46 PM

Maybe you are looking for