Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

date

Former Member
0 Likes
1,020

HI

if i want that what every date i have ......

what is the syntax to get the date which is exactly six month before the given date

like if i have date

15/7/2007

want date 15/1/2007

regards

Nutan

1 ACCEPTED SOLUTION
Read only

former_member188829
Active Contributor
0 Likes
996

Hi,

Use the FM:RP_CALC_DATE_IN_INTERVAL

DATA:date1 TYPE d VALUE '20080606'.
DATA:date2 TYPE d.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date      = date1
    days      = '00'
    months    = '06'
    signum    = '-'
    years     = '00'
  IMPORTING
    calc_date = date2.

WRITE:date2.

In Your Case see the Below Program.

DATA:date(10) TYPE c VALUE '15/07/2007'.
DATA:date_output(10) TYPE c.

DATA:date1 TYPE d.
CONCATENATE date+6(4) date+3(2) date+0(2) INTO date1.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date      = date1
    days      = '00'
    months    = '06'
    signum    = '-'
    years     = '00'
  IMPORTING
    calc_date = date1.


CONCATENATE date1+6(2) '/' date1+4(2) '/' date1+0(4) INTO date_output.

WRITE:/ date_output.

9 REPLIES 9
Read only

former_member188829
Active Contributor
0 Likes
997

Hi,

Use the FM:RP_CALC_DATE_IN_INTERVAL

DATA:date1 TYPE d VALUE '20080606'.
DATA:date2 TYPE d.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date      = date1
    days      = '00'
    months    = '06'
    signum    = '-'
    years     = '00'
  IMPORTING
    calc_date = date2.

WRITE:date2.

In Your Case see the Below Program.

DATA:date(10) TYPE c VALUE '15/07/2007'.
DATA:date_output(10) TYPE c.

DATA:date1 TYPE d.
CONCATENATE date+6(4) date+3(2) date+0(2) INTO date1.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date      = date1
    days      = '00'
    months    = '06'
    signum    = '-'
    years     = '00'
  IMPORTING
    calc_date = date1.


CONCATENATE date1+6(2) '/' date1+4(2) '/' date1+0(4) INTO date_output.

WRITE:/ date_output.

Read only

Former Member
0 Likes
996

Hi,

U can do it with the following function module.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date =

days =

months =

  • SIGNUM = '+'

years =

  • IMPORTING

  • CALC_DATE =

.

Read only

Former Member
0 Likes
996

In sap system date is in the format of YYYYMMDD

so do calulations in same pattern.

Eg: date1 = sy-datum - '00000600'

here date1 is variable storing the value six month before.

Read only

former_member386202
Active Contributor
0 Likes
996

Hi,

Use FM CCM_GO_BACK_MONTHS

Regards,

PRashant

Read only

Former Member
0 Likes
996

Hi

Try this -

DATA: date type d VALUE '15.07.2008',

date_check type d.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = date

days = '00'

months = '06'

signum = '-'

years = '00'

IMPORTING

calc_date = date_check.

Hope this helps

regds

Seema

Read only

Former Member
0 Likes
996

Hi, use following FM,

ur inp_date is 15/07/2007, u vl get oup_date as 15.01.2007.

ur inp_date value should be 20070715.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

currdate = inp_date

backmonths = '006'

IMPORTING

newdate = oup_date.

reward pts if it helps............

Read only

Former Member
0 Likes
996

Hi,

Have a look on the following function module.

Through this function module you can get the date either before/after the current month date

data: var1 type sy-datum.

CALL FUNCTION 'HR_PT_ADD_MONTH_TO_DATE'

EXPORTING

dmm_datin = sy-datum

dmm_count = '6'

dmm_oper = '-' " Operation (add/subtract)

dmm_pos = 'B' " Set date in the beginning or end of month

IMPORTING

DMM_DAOUT = VAR1

EXCEPTIONS

UNKNOWN = 1

OTHERS = 2.

write:/ sy-datum.

write:/ var1.

Reward,if useful.

Thanks,

Chandu

Read only

Former Member
0 Likes
996

Hi.......

Try to use the Function Module CCM_GO_BACK_MONTHS.

Thanks.

Read only

Former Member
0 Likes
996

Hi use FM RP_CALC_DATE_IN_INTERVAL

Add or subtrct interval to a date.

Other useful FMs related to date are :

HR_JP_MONTH_BEGIN_END_DATE

First Date and Last date of the month

HR_IN_GET_DATE_COMPONENTS

Gets the components of a date

FIRST_AND_LAST_DAY_IN_YEAR_GET

Get First Date and Last Date of a year

HR_SGPBS_YRS_MTHS_DAYS

Find the difference between two days

Please assign points if helpful