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

CALCULATE_DATE

Former Member
0 Likes
2,321

When I call the function module CALCULATE_DATE with input MONTHS=1 and START_DATE=20080131, I get RESULT_DATE=00000000, where one would expect the last date of February to be returned.

Am I not using this function correctly?

1 ACCEPTED SOLUTION
Read only

former_member386202
Active Contributor
0 Likes
1,467

Hi,

Use this function Module

CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'

EXPORTING

months = '2'

olddate = lv_date

IMPORTING

newdate = lv_newdate.

Regards,

Prashant

When I call the function module CALCULATE_DATE with input MONTHS=1 and START_DATE=20080131, I get RESULT_DATE=00000000, where one would expect the last date of February to be returned.

Am I not using this function correctly?

4 REPLIES 4
Read only

former_member386202
Active Contributor
0 Likes
1,468

Hi,

Use this function Module

CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'

EXPORTING

months = '2'

olddate = lv_date

IMPORTING

newdate = lv_newdate.

Regards,

Prashant

Read only

Former Member
0 Likes
1,467

Hi, Sir,

Please do reward if useful.

Thankx.

Please see the FM below :

data: wa_date like sy-datum.

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = '20080229'

days = 0

months = 24

signum = '-'

years = 0

importing

calc_date = wa_date.

YOu could also use the function module 'CCM_GO_BACK_MONTHS'

*Func mod will return the date six months before current date

call function 'CCM_GO_BACK_MONTHS'

exporting

currdate = w_curr_date

backmonths = c_number_of_months

importing

newdate = w_six_months_old_date.

Read only

Former Member
0 Likes
1,467

Hi,

You can use these function modules too for calculating the future date :

Function Modules related to Date and Time Calculations

CALCULATE_DATE : Calculates the future date based on the input .

DATE_TO_DAY : Returns the Day for the entered date.

DATE_COMPUTE_DAY : Returns weekday for a date

DATE_GET_WEEK : Returns week for a date

DAY_ATTRIBUTES_GET : Returns attributes for a range of dates specified

MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.

END_OF_MONTH_DETERMINE_2 : Determines the End of a Month.

HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.

FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.

MONTH_NAMES_GET : Get the names of the month

WEEK_GET_FIRST_DAY : Get the first day of the week

HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format

SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours

L_MC_TIME_DIFFERENCE : Find the time difference between two date/time

HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months

LAST_DAY_OF_MONTHS : Returns the last day of the month.

Hope you will try with these function modules.

Thanks,

Sakthi C

*Rewards if useful*

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,467

hi Lieven,

pls. note the out date has to be date type as well.

DATA : in TYPE sy-datum,
<b>       out TYPE sy-datum.</b>

in = sy-datum.

CALL FUNCTION 'CALCULATE_DATE'
 EXPORTING
*   DAYS              = '0'
   months            = '1'
   start_date        = in
 IMPORTING
   result_date       = out.

hope this helps

ec