Last date of Month based on SY_DATUM.

Hi All,
I need last date for a month based on SY-DATUM.
Is there any FM which fulfills above criteria.
Regards,
Yugesh A.
Moderator message: date calculation questions = FAQ, please search before posting.
Edited by: Thomas Zloch on Mar 21, 2011 12:39 PM

Hi,
  Here is the small piece of code u can do some changes according to ur need i hope u will get some help....
data:l_month type am_monat,
     l_year type gjahr,
     f_date type sy-datum,
     l_date type sy-datum.
l_month = 04.
l_year = 2008.
data: fdate type sy-datum.
data:ldate type sy-datum.
CALL FUNCTION 'OIUREP_MONTH_FIRST_LAST'
EXPORTING
   I_MONTH           = l_month
   I_YEAR            = l_year
  I_DATE            =
IMPORTING
   E_FIRST_DAY       = f_date
  E_LAST_DAY        = l_date
EXCEPTIONS
  WRONG_DATE        = 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:/ f_date.
write:/ l_date.
fdate = f_date.
ldate = l_date .
write:/ fdate dd/mm/yyyy.
write:/ ldate dd/mm/yyyy.
Thanks & Regards
Ashu Singh

Similar Messages

  • 1st & last day of month based on month selected

    Hi All,
    I am an infant in BO. I want to create a variable in which I need to compare Order Creation Date with First Day of Month and Last Day of Month.
    I have gone through the posts here regarding this, I found huge no of posts on calculating the 1st & last day of month based on a date value. But,
    I don't have any date objects in the universe level, instead I have only Month Name/Month Number objects in the universe level (as it is a monthly report)
    So, How to create 1st day & last day of month based on the month selected.
    That is, If I run the report for FEB 2011 (Prompt values), I need the outputs as 01/02/2011 & 28/02/2011 as my 1st & last date values respectively.
    I am working on BOXI R 3.1
    Thanks in Advance,
    Mitch

    Hi
    Create a variables and write a formula like
    Also add Month number Object in query level
    Var_Month
    =userresponse("Enter Month")
    Var_A
    "01/"MonthNumberObj+Right(var_Month;4)
    var_First date
    Todate(var_A;"dd/MM/yyyy")
    var_lastdate
    =lastdayofmonth(var_Firstdate)
    Note: check the default format for date according to ur database like MM/dd/yy or something like that . and add in the var_firstdate
    regards
    Sunil

  • Customer Exit for Number of Days from 1 st Apr to last date of Month Enter

    Hello BI Experts,
    I have a requirement to count the number of days from 1 st April of current year to the last date of month entered.
    For example : The use will enter say July 2010 or 003.2010  (as Fiscal Year Variant is V3 ).
    Today is 14 July ...So we have to first find out the end date of the July month ie 31 st July
    Then go to 1 st April 2010.
    Now calculate the Number of days between 1 st April to 31 st July 2010.
    I consider I have to create two Customer Exit variable
    as below
    1 st customer exit Bex variable  say  ZLY_MTH  ( Last day of Month Entered)
      and i_step = 1
    2 nd Customer Exit BEx Formula variable say ZF_NUMDAYS ( Number of days between two dates)
    i_step =1 .
    Please provide me the logic for the above two.
    Thanks in Advance.
    Regards,
    Amol Kulkarni

    PSUDEO CODE:
    1. Initially LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZMONTH'.
    2. Get the Month input using VAR_MONTH2 = LOC_VAR_RANGE-LOW+4(2)
    3. Now calculate Month+1: VAR_MONTH2 = VAR_MONTH2 + 1 (Refer **)
    4. Now calculate the Current Year: VAR_YEAR = LOC_VAR_RANGE-LOW+0(4).
    5. Get the 1st Day of the Month (VAR_MONTH2):  CONCATENATE '01' '/' VAR_MONTH2 '/' VAR_YEAR INTO L_S_RANGE-LOW.
    6. SUBRACT 1 (0DATE) from this DATE (This will give the logic for last day of the current month)
    Insert this code also for using the date conversions
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = VAR_MONTH2
              IMPORTING
                OUTPUT = VAR_MONTH2.
    Pls. check out this logic. Guess it would solve your need.
    Thanks,
    Arun Bala

  • Get first and last date of month

    Hi,
      Is there any function module to get first and last date of month for a entered date.
    Please let me know.
    Regards,
    SP

    Hi,
    Use the below FM to find the Last day of month and them u can easily calculate the first day.
    DATA : v_startdate TYPE sy-datum.
    DATA : v_enddate TYPE sy-datum.
    DATA : v_temp TYPE dats.
    v_temp = sy-datum.
    CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
        EXPORTING
          day_in            = v_temp
        IMPORTING
          last_day_of_month = v_enddate
    CONCATENATE  v_enddate+0(6)  '01'  INTO  v_startdate.
    Hope it helps.
    Regards,
    Arnab.

  • How to find last date of month

    Dear  All,
    Can anybody tell me how to find last date of month I need it to check some validations
    helpful answer will definatly rewarded
    Regards
    Shashikant

    Hi,
    RP_LAST_DAY_OF_MONTHS Determine last day of month
    HR-D: Payroll Germany code
    RP_LAST_DAY_OF_MONTHS
    HR-D: Determine last day of month
    DATE_CONVERT_TO_FACTORYDATE
    Returns factory calendar date for a date Calculates and returns factory calendar date for a date (if CorrectOption = '+');
    Checks if the date is work day (if CorrectOption = '-').
    HOLIDAY_CHECK_AND_GET_INFO Useful for determining whether or not a date is a holiday. Give the function a date, and a holiday calendar, and you can determine if the date is a holiday by checking the parameter HOLIDAY_FOUND.

  • How to get last date of month ?

    Dear all
    hi!!!
    How can I get the last date of a particular month?
    I mean if the month is Feb, last date of the month should be 28.
    Is it required to write in loop or there is any method to get it.
    Please write me urgently,
    thanx,
    Samir

    Hello ,
    You can get the last date of a particular month of a particular year like this :
    int year= 2000;
    int month=1;     // February (month is zero based )
    int date = 20;
    java.util.GregorianCalendar gc = new java.util.GregorianCalendar(year,month,date);
    int last_day = gc.getActualMaximum(Calendar.DAY_OF_MONTH));
    Sandip

  • Last date of month

    Hi im new to java. Looking for a class that provides last date of the month according to a given year and month .

    java does provide a calendar object for gregorian
    dates.. surprising its called GregorianCalendar. :PAs I said avoid GregorianDate in Java it is a poor implementation. Date arithmetic is overly complex. There are inconsistencies i.e. Month starts at zero Jan is 0 day of week starts at 1 (Sunday = 1, Monday = 2) First of the month is 0 not 1 as one would expect. Sun's date does not handle dates prior to 1970 ( a real pain in your are doing historical data analysis). Suns Date uses 2 digit years.
    BigDate makes date arithmetic a slam dunk.
    To find the second monday in June 1961
    BigDate aDate = new BigDate(BigDate.nthXXXDay( 2, 1, 1961, 6));
    yyyy = aDate.getYYYY();
    mm = aDate.getMM ();
    dd = aDate.getDD ();
    To calculate 156 days after the 1st of Jan 1999. You would do the following.
    BigDate aDate = new BigDate (1999, 1 , 1 + 156, BigDate.NORMALIZE);
    yyyy = aDate.getYYYY();
    mm = aDate.getMM ();
    dd = aDate.getDD ();
    or
    BigDate aDate = new BigDate (1999, 1 , 1 );
    aDate.setOrdinal(aDate.getOrdinal( )+ 156);
    yyyy = aDate.getYYYY();
    mm = aDate.getMM ();
    dd = aDate.getDD ();

  • Getting last date of month

    Dear Experts
    Please help, i am new in ABAP.
    I want to get number of days for a particular month .Eg if user selects feb as moth and 2009 as year i will get 28.02.2009 as output.
    if user selects march and 2009 as year it will automatically returns 31.03.2009..
    Also give me function module coding for selection of month and year.
    I whouls be highly thankful to you for this.
    Regards
    Raj Jindal

    Hi Raj,
    DATA:
      w_date type sy-datum.
    CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
      EXPORTING
        day_in                 = '20090214' " pass the date here for which u want the last date
    IMPORTING
       LAST_DAY_OF_MONTH       = w_date
    EXCEPTIONS
       DAY_IN_NO_DATE          = 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:
      w_date.
    With luck,
    Pritam.

  • URGENT - BI Publisher - Get Last Date of Month/Year

    Hello,
    I want to get the last date of a year/month through BI Publisher. We want to do it by creating a list of values containing the month/year name (i.e. January, February, March for month or 2004 2005 2006 for year) and when the user selects one of this values to get the last date of the month or year in order to select the correct number of records.

    Hi,
    try with a LOV like the following:
    select
    to_char(add_months(trunc(sysdate,'MONTH'),-level),'Month - YYYY') display_value,
    last_day(add_months(trunc(sysdate,'MONTH'),-level)) return_value
    from dual
    connect by level <=12
    which gives you the last 12 month from today.
    Regards
    Rainer

  • Restrict last date of month from date picker

    Hi All,
    I have a requirement to restrict the date picker.
    I want to allow the user to select only the last date of the month from the following four months march, June, September and December.
    I have googled about this i couldn't get related that except that restrict invalid days/months.
    Please suggest to find solution for this.
    My Jdev version is 11.1.2.0.0
    Thanks in advance,
    SAN

    Hi,
    Have a backing bean to construct a list of days to be disabled and set that to disabledDays property of the picker component.
    Ex : Re: Bug on the property "disabledDays" of the component af|inputDate ?
    -Arun

  • FM to find the first & last date of month when we enter period and year

    Hi Gurus,
               I required an urgent need.
               I want a function module which gives me first and the last date of the month when I enter the period and the year.
               Reply me as soon as possible.
    Regards,
    Sagar

    Try this coding...  enter    02/2007 into the selection screen field and execute
    report zrich_0001 .
    data: start_date type sy-datum,
          end_date type sy-datum.
    parameters: p_spbup type spbup.
    start-of-selection.
      start_date = p_spbup.
      start_date+6(2) = '01'.
      call function 'LAST_DAY_OF_MONTHS'
           exporting
                day_in            = start_date
           importing
                last_day_of_month = end_date.
      write:/ start_date, end_date.
    Regards,
    Rich Heilman

  • Ora-01847 day of month between 1 and last date of month coming in my query

    i m executing simple query but it is not working plz do help
    select *
    from sgvf_tree_nodes_vw
    where to_date(node_attr9_val, 'dd/mm/yyyy') between
    to_date('01/01/2010', 'dd/mm/yyyy') and
    to_date('31/12/2010', 'dd/mm/yyyy')
    gives : Ora-01847 day of month should be between 1 and last date of month

    Hi,
    Check the date format's once
    SQL> drop table demo;
    Table dropped.
    SQL> create table demo(val number, todate varchar2(12));
    Table created.
    SQL> insert into demo values(1,'04/11/2008');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from demo;
           VAL TODATE
             1 04/11/2008
    SQL> select sysdate from dual;
    SYSDATE
    03-FEB-11
    SQL> insert into demo values(1,'04/11/2010');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select *
      2  from demo
      3  where to_date(todate,'dd/mm/yyyy') between to_date('01/01/2010', 'dd/mm/yyyy') and to_date('31/12/2010', 'dd/m
    m/yyyy');
           VAL TODATE
             1 04/11/2010- Pavan Kumar N

  • First & Last date of month

    Hello Everyone ,
    Does anyone knows any function module or way to find the first and last date of any month ?
    Thanks,
    Deepak.

    Hi,
    Try the following
    DATA: l_first_date LIKE SY-DATUM,
          l_last_date  LIKE SY-DATUM.
    PARAMETER l_Date LIKE SY-DATUM DEFAULT SY-DATUM.
    First day of month
    CONCATENATE l_date(6) '01' INTo l_first_date.
    call function 'HR_HCP_GET_LAST_DAY_OF_MONTH'
      exporting
        im_date                    = l_date
      IMPORTING
        EX_LAST_DAY_OF_MONTH       = l_last_date.
    WRITE:/ l_first_date.
    WRITE:/ l_last_date.

  • RE: FM to get last date of month

    Hi,
    Please tell me if there is a function to return the last day of the month.
    The input is year+month
    eg 200710 should return a date 31.10.2007
    I noticed that most of the function needs a date, ie DDMMYYYY

    Hi,
    use RP_LAST_DAY_OF_MONTHS
    SELECT-OPTIONS: S_DATE FOR SY-DATUM.
    DATA: V_DATE1 LIKE SY-DATUM,
    V_DATE2 LIKE SY-DATUM.
    DATA: P_INTRANGE LIKE RSINTRANGE OCCURS 0 WITH HEADER LINE.
    INITIALIZATION.
    CALL FUNCTION 'RS_VARI_V_1_LAST_MONTH'
    IMPORTING
    P_DATE = V_DATE1
    TABLES
    P_INTRANGE = P_INTRANGE.
    CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
    EXPORTING
    DAY_IN = SY-DATUM
    IMPORTING
    LAST_DAY_OF_MONTH = V_DATE2
    EXCEPTIONS
    DAY_IN_NO_DATE = 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.
    S_DATE-LOW = V_DATE1.
    S_DATE-HIGH = V_DATE2.
    APPEND S_DATE.
    Check this link also,
    current month
    Thanks,
    Reward If Helpful.

  • Function to find the Last Date of Month One Year Ago - RETURNS ERROR

    I've written sql code which takes a date and finds the Last Day of the Month one year ago. For example,  it takes the date '2015-04-17' and returns the date '2014-04-30'. The code works fine in a query. Now I'm trying to turn this into a function. However,
    when I try to create the function I get the error:
    Operand type clash: date is incompatible with int
    Why is this error being returned?
    Here is my function:
    CREATE FUNCTION dbo.zEOM_LY_D(@Input Date)
           RETURNS date
    AS
    BEGIN;
      DECLARE @Result date;
      SET @Result =  convert(DATE, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
        RETURN @Result;
    END;
    Thanks for any help you can give.
                     

    Stan,
    Thanks very much- that does the trick. I should have said I am using SQL 2008 so EOMONTH is not available to me. I still don't get why I got an error though, since I was treating a date like a date and not like an int.
    Thanks, John
    I think i found the issue but i do not know why it is causing the issue. i think may be the way dates are treated/stored internally..i think dates are stored as no of days after 0001/01/01 but cannot see how this cwould effect..may be somebody else can through
    some light..... 
    if you make it as datetime it will work,
    if you leave it as date - eliminate adding 1...  you should prefer to use dateadd to add/substract dates.
    try this to understand..
    --removed the +1 in the code
    declare @input date
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)),0)),101)
    go
    --made the datatype as datetime
    declare @input datetime
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
    Hope it Helps!!

Maybe you are looking for

  • FPN: No ESID found error while invoking BEx iviews for Reports.

    Hi Everybody, We have a federated portal network [FPN] setup. We are EP 7 SP15 for both Consumer portal and BI producer portal. The content is delivered to users via RRA Remote Role Assignment ] in consumer portal for BI portal roles from Producer bi

  • Safari will no longer play apple tutorials on the web

    I've only had my mac for a couple of days and somehow safari will no longer play apple tutorials. If I click on one, it just loads and loads but never plays. Firefox doesn't work either. Somehow this feels quicktime related. My system is brand new. I

  • Having a hard time with FF XIII and wine

    Hi there! I'm trying to run Final Fantasy XIII on wine. I installed it through Steam. I've seen this page, but my problems don't seem to be addressed there and I don't know what to do. When I run the game from steam, I get no feedback whatsoever. The

  • Dynamic filename access

    Hi all, I am trying to do dynamic file renaming for my file to file scenario. I mapped the filename to an output field and i can see it in Technical Ruoting/Payload in sxmb_moni also. But I am unable to generate the file using the variable substituti

  • Documents Print with Blurry Text in Acrobat Pro 9

    I'm running Acrobat Professional 9 on a Windows XP machine.  I recently upgraded to version 9 from version 7.  When I print files in color in version 9, the documents come out with bold-faced font and the text is a little blurry.  The document prints