Date to Month and Year

Hi Guru's
We have a requirement of taking the input in date/month/year format in the DSO and the output to be displayed in the report is in month/year in the report.
We dont want to do any changes/modification in the DSO level.
Any ideas on how to do it.
Thanks
Krishna

Hi,
Using the following code you can do it, but in columns you want to display the month, it is mot possible, i.e. JAN-08, FEB-08 like that it is not possible without adding new InfoObject in DSO. It works for Text variables.
'ZDATE_U' =   Normal Variable for Calday user entry.
'ZMONTH_E'. = Customet Exit for Calmonth
when 'ZMONTH_E'.
DATA: zdtt(8) TYPE c,
            w_mnth(3) TYPE c.
      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDATE_U'.
        CLEAR l_s_range.
        w_day = loc_var_range-low+6(2).
        w_mon  = loc_var_range-low+4(2).
        w_year = loc_var_range-low+0(4).
        CASE w_mon.
          WHEN '01'.
            w_mnth = 'JAN'.
          WHEN '02'.
            w_mnth = 'FEB'.
          WHEN '03'.
            w_mnth = 'MAR'.
          WHEN '04'.
            w_mnth = 'APR'.
          WHEN '05'.
            w_mnth = 'MAY'.
          WHEN '06'.
            w_mnth = 'JUN'.
          WHEN '07'.
            w_mnth = 'JUL'.
          WHEN '08'.
            w_mnth = 'AUG'.
          WHEN '09'.
            w_mnth = 'SEP'.
          WHEN '10'.
            w_mnth = 'OCT'.
          WHEN '11'.
            w_mnth = 'NOV'.
          WHEN '12'.
            w_mnth = 'DEC'.
        ENDCASE.
       CONCATENATE w_day '-' w_mnth '-' w_year INTO zdtt.
       CONCATENATE w_mnth '-' w_year INTO zdtt.
        CONCATENATE w_mnth '-' w_year+2(2) INTO zdtt.
        l_s_range-low = zdtt.
        l_s_range-sign = 'I'.
        l_s_range-opt = 'EQ'.
        APPEND l_s_range TO e_t_range.
      ENDLOOP.
Thanks
Reddy

Similar Messages

  • I want to keep date special month and year.

    I want to keep date special month and year.
    Example in sqlplus
    insert into area(input_time) values(to_date('MAR-04','MON-YY'));
    and select
    select input_time from area;
    the result
    01 MAR 2004
    in Oracle
    01-MAR-2004 12:00:00 AM
    I don't keep day, but I want to keep month and year.
    Can you do?
    Thanks.

    An Oracle date column must contain a date down to the second. If you don't specify a day or a time, it will default to the first of the month and midnight.
    If you want a column to only contain values at the beginning of a particular month, you can create a CHECK constraint that verifies that
    input_time = trunc( input_time, 'MM' )Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Convert Date to Month and Year

    Hi,
    I am currently using Function Module CONVERSION_EXIT_LDATE_OUTPUT to convert a date example 20090901 to 01 September 2009.
    Using z_date+3 then zdate becomes September 2009 which is what i require.
    In the report when I actually sort by month it doesn't really work well example below.
    September 2009
    September 2010
    October 2009
    October 2010
    November 2009
    November 2010
    It should really be like the below. I dont want to covert the date to 09.2009 i want it to be September 2009 hence i have taken this approach. Any help would be appreciated.
    September 2009
    October 2009
    November 2009
    September 2010
    October 2010
    November 2010
    Regards
    Adeel

    as you are storing it into one string, its just sorting on the basis of string comparison which starts from first later.
    store them to two different fields.
    like
    data : BEGIN OF gt_dt OCCURS 0,
            mnth type string,
            year type n LENGTH 4,
           end of gt_dt.
    DATA : s1 TYPE string,
          i1 type i.
    *lets say here you get the values to this table like:
    s1 = '01 September 2009'.
    shift s1 by 3 PLACES left.
    i1 = strlen( s1 ).
    i1 = i1 - 4.
    gt_dt-mnth = s1+0(i1).
    shift s1 by i1 PLACES left.
    gt_dt-year = s1.
    APPEND gt_dt.
    s1 = '01 September 2010'.
    shift s1 by 3 PLACES left.
    i1 = strlen( s1 ).
    i1 = i1 - 4.
    gt_dt-mnth = s1+0(i1).
    shift s1 by i1 PLACES left.
    gt_dt-year = s1.
    APPEND gt_dt.
    s1 = '01 October 2009'.
    shift s1 by 3 PLACES left.
    i1 = strlen( s1 ).
    i1 = i1 - 4.
    gt_dt-mnth = s1+0(i1).
    shift s1 by i1 PLACES left.
    gt_dt-year = s1.
    APPEND gt_dt.
    s1 = '01 October 2010'.
    shift s1 by 3 PLACES left.
    i1 = strlen( s1 ).
    i1 = i1 - 4.
    gt_dt-mnth = s1+0(i1).
    shift s1 by i1 PLACES left.
    gt_dt-year = s1.
    APPEND gt_dt.
    now you can sort as you wish.

  • Get start and end week date by month and year

    How I need the week is by this -- a week always starts on a sunday so for feburary it will be
    start week end week
    12-02-1 12-02-04
    12-02-05 12-02-11
    12-02-12 12-02-18
    12-02-19 12-02-25
    12-02-26 12-29-29
    So because the first week does not start on a sunday it goes from
    1(wednesday) to 4th(saturday) Just like a calendar.
    Thanks in advance
    so far from Solomons help I have this
    This is for january
    WITH t AS (
    SELECT TRUNC(TRUNC(to_date('01-01-12','MM-DD-YY'),'YYYY') -1,'W') + (LEVEL-1 ) * 7 week_start_date
    FROM DUAL
    CONNECT BY LEVEL <= 53
    SELECT week_start_date,
    LEAST(LAST_DAY(to_date('01-01-12','MM-DD-YY')),week_start_date + 6) week_end_date
    FROM t
    WHERE week_start_date >= TRUNC(to_date('01-01-12','MM-DD-YY'),'MM')
    AND week_start_date < ADD_MONTHS(TRUNC(to_date('01-01-12','MM-DD-YY'),'MM'),1)
    start week end week
    12-01-02     12-01-08
    12-01-09     12-01-15
    12-01-16     12-01-22
    12-01-23     12-01-29
    12-01-30     12-01-31

    If week satrts Sunday:
    WITH t AS (
               SELECT TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 week_start_date
                FROM  DUAL
                CONNECT BY TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 <= LAST_DAY(&dt)
    SELECT  GREATEST(week_start_date,TRUNC(&dt,'MM')) week_start_date,
            LEAST(LAST_DAY(&dt),week_start_date + 6) week_end_date
      FROM  t
      WHERE week_start_date <= LAST_DAY(&dt)
    /For example:
    SQL> SET VERIFY OFF
    SQL> DEFINE dt="DATE '2012-01-17'" -- January
    SQL> WITH t AS (
      2             SELECT TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 week_start_date
      3              FROM  DUAL
      4              CONNECT BY TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 <= LAST_DAY(&dt)
      5            )
      6  SELECT  GREATEST(week_start_date,TRUNC(&dt,'MM')) week_start_date,
      7          LEAST(LAST_DAY(&dt),week_start_date + 6) week_end_date
      8    FROM  t
      9    WHERE week_start_date <= LAST_DAY(&dt)
    10  /
    WEEK_STAR WEEK_END_
    01-JAN-12 07-JAN-12
    08-JAN-12 14-JAN-12
    15-JAN-12 21-JAN-12
    22-JAN-12 28-JAN-12
    29-JAN-12 31-JAN-12
    SQL> SET VERIFY OFF
    SQL> DEFINE dt="DATE '2012-02-25'" -- February
    SQL> WITH t AS (
      2             SELECT TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 week_start_date
      3              FROM  DUAL
      4              CONNECT BY TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 <= LAST_DAY(&dt)
      5            )
      6  SELECT  GREATEST(week_start_date,TRUNC(&dt,'MM')) week_start_date,
      7          LEAST(LAST_DAY(&dt),week_start_date + 6) week_end_date
      8    FROM  t
      9    WHERE week_start_date <= LAST_DAY(&dt)
    10  /
    WEEK_STAR WEEK_END_
    01-FEB-12 04-FEB-12
    05-FEB-12 11-FEB-12
    12-FEB-12 18-FEB-12
    19-FEB-12 25-FEB-12
    26-FEB-12 29-FEB-12
    SQL> SET VERIFY OFF
    SQL> DEFINE dt="DATE '2012-03-07'" -- March
    SQL> WITH t AS (
      2             SELECT TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 week_start_date
      3              FROM  DUAL
      4              CONNECT BY TRUNC(TRUNC(&dt,'MM') + 1,'IW') - 1 + (LEVEL - 1) * 7 <= LAST_DAY(&dt)
      5            )
      6  SELECT  GREATEST(week_start_date,TRUNC(&dt,'MM')) week_start_date,
      7          LEAST(LAST_DAY(&dt),week_start_date + 6) week_end_date
      8    FROM  t
      9    WHERE week_start_date <= LAST_DAY(&dt)
    10  /
    WEEK_STAR WEEK_END_
    01-MAR-12 03-MAR-12
    04-MAR-12 10-MAR-12
    11-MAR-12 17-MAR-12
    18-MAR-12 24-MAR-12
    25-MAR-12 31-MAR-12
    SQL> SY.
    Edited by: Solomon Yakobson on Jan 12, 2012 1:19 PM

  • Select-options split date into month and assign to low and high

    Hi,
       In my select-options i am giving BEDAT (01.04.2004 TO 30.10.2005).I need to split month and
    year in separate fields.that is
    select-option_low-month in one field
    select-option_high-month in second field
    select-option_low-year in third field
    select-option_high-year in fourth field.
    Finally i need to move these four fields to it_final.
    select * from mbewh into corresponding fields of table it_mbewh
               for all entries in it_final where matnr = it_final-matnr and
               bwkey = it_final-werks and lpmon = ? and lfgja = ?
               and  bklas <> ' '.
    what input i have to give in lpmon and lfgja in select query to get for lfmon (04 to 10)
    and lfgja (2004 to 2005).
    suggest some ideas.

    Hi ,
    Can you please check the following code.
    Hi ,
    data :  l_low_yr(4),
              l_high_yr(4),
              l_low_mon(2),
              l_high_mon(2).
    Splitting the select option date to month and year into low and higher values
    l_low_yr        =   s_date-low+00(04). "  Year low value from the date range
    l_low_mon    =   s_date-low+04(02). "  Month low value from the date range
    l_high_yr      =   s_date-high+00(04)."  Year high value from the date range
    l_high_mon   =   s_date-high+04(02)." Month high value from the date range
    selecting the data from the table mbewh based on some conditions.
    select * from mbewh into corresponding fields of table it_mbewh
               for all entries in it_final where matnr = it_final-matnr and
               bwkey = it_final-werks and lfmon BETWEEN  l_low_mon and l_high_mon
    and lfgja BETWEEN l_low_yr and l_high_yr   and  bklas EQ  ' '.
    This select will retrive the desired data records from the table MBEWH.
    Please let me know if this works according to your requirement.
    Thanks and Regards
    Saritha

  • How to get Week,Month and Year details from a date column

    Hi frenz,
    I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
    I need month and year details as well based on this tran_date column.... can any one tell me how...
    Thanks in advance

    My example for objects:
    create or replace type date_object as object
      centure number,
      year    number,
      month   number,
      day     number,
      hour    number,
      minute  number,
      second  number,
      daypart number,
      week    number,
      constructor function date_object(p_dt date)
        return SELF as result
    create or replace type body date_object is
      constructor function date_object(p_dt date)
        return SELF as result
      as
      begin
        SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
        SELF.year:=    to_char(p_dt,'YYYY');
        SELF.month:=   to_char(p_dt,'MM');
        SELF.day:=     to_char(p_dt,'DD');
        SELF.hour:=    to_char(p_dt,'HH24');
        SELF.minute:=  to_char(p_dt,'MI');
        SELF.second:=  to_char(p_dt,'SS');
        SELF.daypart:= p_dt-trunc(p_dt,'DD');
        SELF.week:=    to_char(p_dt,'IW');
        return;
      end;
    end;
    select date_object(sysdate),
           date_object(sysdate).year
    from dual;Regards,
    Sayan M.

  • Data element for Month and Year

    Hello All,
    Is there any data element which will have only Month and Year.
    I have to introduce this field in a table. It should have convesion exits also.
    Ex: If i give 092009, it sould come like 09.2009
    Thank you.
    Best Regards,
    Sasidhar Reddy Matli.

    Kindly Try this code for Month and year as input and having standard F4 help..
    INCLUDE RMCS0F0M.
    TYPES : BEGIN OF TY_SELECT,
              MONTH TYPE FTI_MONTH_YEAR,
            END OF TY_SELECT.
    DATA : WA_SELECT TYPE TY_SELECT.
    SELECTION-SCREEN : BEGIN OF BLOCK SANDEEP WITH FRAME.
      SELECT-OPTIONS : S_MONTH FOR WA_SELECT-MONTH OBLIGATORY NO INTERVALS NO-EXTENSION.
    SELECTION-SCREEN : END OF BLOCK SANDEEP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MONTH-LOW.
      PERFORM MONAT_F4.
    SANDEEP JAIN

  • Problem to insert only month and year instead of full date

    select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
            b.epd, b.lpd
    from prl_daftar_proses a, senarai_pesalah b, penjara p
    where a.no_daftar=b.no_daftar
    and a.episod=b.episod
    and b.penjara_id = p.penjara_id
    and a.setuju_jplp is null
    and a.bulan_proses between to_date(:FROM,'dd/mm/yyyy') and to_date(:TO,'dd/mm/yyyy')
    order by b.penjara_id, a.bulan_proses,a.no_daftarHi,anyone can help me how i can insert only month and year from the value that have full date in the database??
    for example,the date is 09/18/2012, but i just want to insert 09/2012 as parameter. If i want to insert only one parameter, i can do that..But i have problem when I want to insert two parameters..

    jeneesh wrote:
    Welcome to the forum..
    This..?
    Assuming bulan_proses is a date without time part
    select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
            b.epd, b.lpd
    from prl_daftar_proses a, senarai_pesalah b, penjara p
    where a.no_daftar=b.no_daftar
    and a.episod=b.episod
    and b.penjara_id = p.penjara_id
    and a.setuju_jplp is null
    and a.bulan_proses between to_date(:FROM,'mm/yyyy') and last_day(to_date(:TO,'mm/yyyy'))
    order by b.penjara_id, a.bulan_proses,a.no_daftar
    i got another problem..
    before that.may i know what is the function of last_day?

  • To get first date and end date after entering any month and year

    Hi,
    I need to to get first date and end date of a month and year in yyyyMMdd format. I am reading month and year from a properties file. But I don't know how to get the first date and End date in given format. The properties file gives me just text. But I don't know how to get the date format using this. I need this urgently. Can anyone help me to get code for this?
    I am reading the fields as,
    Properties props = new Properties();
    props.load(new FileInputStream("AnyMonthVolume.properties"));
    String date_month = props.getProperty("date_month");
    String date_year = props.getProperty("date_year");
    Thanks.

    I know this has been posted a while ago but incase someone looking for it, here is the code to get the end of current month date.
    Calendar cal = Calendar.getInstance();
         cal.setTime(new java.util.Date());
         cal.set(Calendar.DATE, 1); //set the date to start of month
         cal.add(Calendar.MONTH,1);
         cal.add(Calendar.DATE,-1);
    System.out.println(cal.getTime());

  • Is there a way to change the date format so that delegates have to choose a day, month and year from a drop down menu as my delegates keep forgetting to change the year of their information

    When my delegates are filling in a event form i have put together, a large number of them forget to change either the month or year on the date field. Is there a way to have a date field that has drop down boxes for day, month and year so they have to choose rather than a date been already on the screen??
    Thanks

    Hi Christopher,
    The WEEKDAY function allows specifying either Sunday or Monday as the first day of the week:
    WEEKDAY
    The WEEKDAY function returns a number that is the day of the week for a given date. WEEKDAY(date, first-day)
      date:  The date the function should use. date is a date/time value. The time portion is ignored by this function.
      first-day: An optional value that specifies how days are numbered.
    Sunday is 1 (1 or omitted):  Sunday is the first day (day 1) of the week and Saturday is day 7.
    Monday is 1 (2):  Monday is the first day (day 1) of the week and Sunday is day 7. Monday is 0 (3):  Monday is the first day (day 0) of the week and Sunday is day 6.
    But I think you are referring to the first day of the 'workweek', for which I do not see a means of defining a custom value.
    Since you want to 'insert categories', though, you could easily define your own, using WEEKDAY(date) or WEEKDAY(date,1), plus an IF statement to return the category label appropriate to the day. Here's one for a Sunday to Thursday work week. Dates are in column A, the formula is in whichever column you want as the Category column. For the example, I've placed it in column B.
    B2, and filled down: =IF(WEEKDAY(A)<6,"Work","Off")
    The top table shows the weekday numbers returned for each day of the week for each of the three permitted values for the optional second argument. The bottom table shows the results from the formula above, used to define a category label for each date:
    A10 was left blank intentionally, to determine if the lack of data resulted in an error. The Warning message, flagged by the blue 'warning' triangle, is "The formula uses a number in place of a date." The 'date' assigned to this numerical value of zero was a Friday, but I'm not certain when. Probably best to avoid extra rows with no date shown.
    Regards,
    Barry

  • Anyone help me ...I am writing to get Date, Month and Year...I got errors

    Could some body help me:
    I am try to get Date, Month and Year
    I got stuck, Anyone help me this:
    public class DateMonth
    public static void main(String[] args)
    toDay = new toDay("February 21, 2002");
    dayofWeek = today.getDay();
    System.out.println("Current month is " + toDay.getMonth());
    System.out.println("Current day is " + getDate());
    System.out.println("Current year is " + toDay.getYear());
    toDay.setDate(toDay.getDate()+60)
    System.out.println("Sixty days from now is ");
    System.out.println(toDay);
    }

    Try something like this:
    import java.util.*;
    public class DateMonth {
         public static void main(String[] args) {
              // Note: 0 = January
              Calendar calendar = new GregorianCalendar();
              System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
              System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
              System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
              System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
              System.out.println("DATE: " + calendar.get(Calendar.DATE));
              System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
              System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
              System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
              // 60 days from now
              calendar.add(calendar.DATE, 60);
              System.out.println("\nSixty days from now");
              System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
              System.out.println("DATE: " + calendar.get(Calendar.DATE));
              System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
    }Remember that January is 0!
    Take a look at the GregorianCalendar class:
    http://java.sun.com/j2se/1.3/docs/api/java/util/GregorianCalendar.html
    Hope this helps!
    DesQuite

  • Find the difference between two dates for the specific month and year

    Hi,
    I have two dates, start date is 30/12/2012 and end date is 04/01/2013. Using datediff I found the difference of days between two dates. But I find the no of days in January 2013. ie output is 4 instead of 6. I input month and year to find the no of days
    for that date. In this case I input Jan 2013. How can I sql this ?

    I don't understand how most of the answers provided here not analytically solving the problem with many cases possible.
    First let me understand you:
    You have 2 dates range and you want to calculate day range for specific month and year between the original date range.
    declare @for_month int = 1 --January
    declare @for_year int = 2013
    declare @StartDate date = '2012-12-20'
    declare @EndDate date = '2013-01-04'
    SELECT
    CASE
    WHEN (DATEPART(MONTH, @StartDate) = @for_month and DATEPART(MONTH, @EndDate) = @for_month) and ((DATEPART(YEAR, @StartDate) = @for_year or DATEPART(YEAR, @EndDate) = @for_year)) THEN
    DATEDIFF(DAY, @StartDate,@EndDate)
    WHEN (@StartDate < cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (@EndDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, DATEADD(MONTH, DATEDIFF(MONTH, -1, @EndDate)-1, 0),@EndDate)
    WHEN (@EndDate > cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) and (@StartDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, @StartDate,DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, @StartDate) + 1, 0))) + 1
    WHEN ((DATEDIFF(DAY, @StartDate, cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) >= 0) and (DATEDIFF(DAY, cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date), @EndDate) >= 0)) THEN
    DATEDIFF(DAY, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime), DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime)) + 1, 0))) + 1
    ELSE
    0
    END as [DD]
    I don't know how you calculate day range between 01/01/2013 and 04/01/2013
    is 4, it is actually is 3 but if that is the case, you can add 1 from the condition.

  • Find month and year of a given date

    Hi,
    How to find the month and year of a given date.
    month ( sy-datum)  year ( sy-datum )
    --Bala

    hi
    DATA: EDAYS LIKE VTBBEWE-ATAGE,
    EMONTHS LIKE VTBBEWE-ATAGE,
    EYEARS LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
    TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    Call Function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
      I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Using teh abiove u can get difference but when u pass previous year u wont get the exact.
    There is no seperate FM for this, u have to use three FM.
    If possible using these three FM code u can create an FM.
    For years and months between two days:
    DATA:   EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE PREL-BEGDA,
                     TODATE   LIKE PREL-BEGDA DEFAULT SY-DATUM.
    CALL FUNCTION 'COMPUTE_YEARS_BETWEEN_DATES'
      EXPORTING
        first_date                        = fromdate
      MODIFY_INTERVAL                   = ' '
        second_date                       = todate
    IMPORTING
       YEARS_BETWEEN_DATES               =  EYEARS
    EXCEPTIONS
      SEQUENCE_OF_DATES_NOT_VALID       = 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:/ eyears.
    DATA:       EMONTHS LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE SY-DATUM,
                TODATE   LIKE SY-DATUM
    DEFAULT SY-DATUM.
    CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
      EXPORTING
        i_datum_bis         = fromdate
        i_datum_von         = todate
      I_KZ_INCL_BIS       = ' '
    IMPORTING
       E_MONATE            = emonths
    write:/ emonths
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
    EXPORTING
    I_DATUM_BIS = x_faede-zfbdt
    I_DATUM_VON = p_fdat
    I_KZ_EXCL_VON = '0'
    I_KZ_INCL_BIS = '0'
    I_KZ_ULT_BIS = ' '
    I_KZ_ULT_VON = ' '
    I_STGMETH = '0'
    I_SZBMETH = '1'
    IMPORTING
    E_TAGE = dias_v.
    IF SY-SUBRC <> 0.
    ENDIF.
    x_faede-zfbdt -> 20050915
    p_fdat -> 20050811
    dias_v = 4
    try this and let me know.
    regards
    ravish
    <b>plz dont forget to reward useful points</b>

  • Date must be truncated to month and year

    Hi,
    I have a date field
    after the user gives F4 help I need to truncate the date , i.e I want only month and year
    For Ex.
    If the user selects as 12/12/2009
    I must display as 12/2009
    How can It be done?

    Hi,
    go thru this threads
    Re: Date validation and conversion
    Re: Is DD/MM/YYYY supported in webdynpro for abap application
    it might provide you some guidance

  • Date Picker: Only select Month and Year

    Hallo,
    I try to configure the Date Picker. For the users it should only be possible to select Month and Year. The column should be automaticly completed with the first day of the select month and a static time (00:00:00).
    How can I do this?
    Sincerly

    You can't do that with a standard date picker. What you could do is to use it and after you change the value in it you modify the value using javascript and ajax similar to what I do in this example:
    http://htmldb.oracle.com/pls/otn/f?p=31517:9
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

Maybe you are looking for

  • ASDM is not working in outside interface

    Hi, I am new to ASA. I have got ASA 5510 and was trying to enable ASDM access through outside interface. but its not working for me.. . I have configured a public ip in outside interface and enabled ssh and asdm. SSH is working but asdm is not workin

  • Facing problem in Weblogic Server 10.0

    Hi,           I migrated one application from Weblogic 5.1 Commerce to weblogic 10. As part of this, Iam facing the below problem. In this migration, I configured all the things in new weblogic 10.0 as in weblogic 5.1.           When I deployed the a

  • How do I capture & save a video which I've seen on a website, and is now (probably) in a temp file somewhere?

    I sometimes see a video on a website that I'd like to save. I'd expect to click on it, and hit [copy], and [paste] it in a folder. Or [Save as...], and give it a name and address. But no: no can do. Is there a utility or plug-in I need, or is there a

  • Problem performing "cleansweep" t

    I am one of the people having the whole "Cannot initialize audio driver..." problems with a Li've! 5. card with XP an SP2 and all that. Checking in numerous places and then finally the sticky at the top of this board I decide a cleansweep is just the

  • Hello, having problem with iMessage

    Hi I have some problems with my iPhone 4S, in the iMessage setup it says awaiting activation? How do I activate? I have hade this function to work before but not now... Best regurads Magnus