Application Development 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: 

FM to calculate date month & year six months previous to the current date

Former Member
0 Kudos

Hi All,

Is there any function module or code to calculate date month & year six months previous to the current date.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use the below function module

RP_CALC_DATE_IN_INTERVAL

you can give '-'(minus) for previous date or '+'(plus) for future date

for the SIGNUM field

<b>example</b>

DATA V_DATE TYPE SY-DATUM.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = SY-DATUM

DAYS = 0

MONTHS = '06'

SIGNUM = '-'

YEARS = 0

IMPORTING

CALC_DATE = V_DATE.

write:/ v_date.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Try CALCULATE_DATE

Reward if useful!

Former Member
0 Kudos

Hi,

Use the below function module

RP_CALC_DATE_IN_INTERVAL

you can give '-'(minus) for previous date or '+'(plus) for future date

for the SIGNUM field

<b>example</b>

DATA V_DATE TYPE SY-DATUM.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = SY-DATUM

DAYS = 0

MONTHS = '06'

SIGNUM = '-'

YEARS = 0

IMPORTING

CALC_DATE = V_DATE.

write:/ v_date.

Former Member
0 Kudos

hi raj,

can u tell me exactly what you want so that i can help. there are manu FM's

like:

RELATIVE_DATE_CALCULATE

SD_DATETIME_DIFFERENCE

RP_CALC_DATE_IN_INTERVAL

DATE_COMPUTE_DAY Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.

DATE_GET_WEEK will return the week that a date is in.

DATE_IN_FUTURE Calculate a date N days in the future.

DAY_ATTRIBUTES_GET Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuesday), whether the day is a holiday, and more.

F4_DATE for popping up calendar for date help on value request

RH_GET_DATE_DAYNAME return the day based on the date provided

RP_CALC_DATE_IN_INTERVAL Add/subtract years/months/days from a date

RP_LAST_DAY_OF_MONTHS Determine last day of month

WEEK_GET_FIRST_DAY For a given week (YYYYMM format), this function returns the date of the Monday of that week.

Reward if useful,

Regards,

Sachin.

Former Member
0 Kudos

hi,

try this

data : date1 like vbak-erdat.

data : q type numc3.

selection-screen : begin of block blk2 with frame title text-001.

parameters : n like q.

selection-screen : end of block blk2.

if n > 0.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

CURRDATE = sy-datum

BACKMONTHS = n

IMPORTING

NEWDATE = date1

.

selection-screen: begin of block blk1 with frame title text-001.

select-options : s_date for vbak-erdat default 'NEWDATE' to 'sy-datum' no-display.

selection-screen : end of block blk1.

write : date1.

Reward with points if helpful.

Former Member
0 Kudos

Nor working

Former Member
0 Kudos

Thanks a lot for your help.

Message was edited by:

raj_abap