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 Calculations

rainer_hbenthal
Active Contributor
0 Likes
1,437

I've been using the FM calculate_date and detected that this FM producers wrong dates in some cases. SAP declares this FM as internal use only and will not fix the problem.

I'm now a little bit in trouble of finding an <b>official</b> FM module doing date calculations, does anybody know some of those? please do not post FM which are declared as internal use, i will not reward points on those useless answers.

I've been using the FM calculate_date and detected that this FM producers wrong dates in some cases. SAP declares this FM as internal use only and will not fix the problem.

I'm now a little bit in trouble of finding an <b>official</b> FM module doing date calculations, does anybody know some of those? please do not post FM which are declared as internal use, i will not reward points on those useless answers.

10 REPLIES 10
Read only

Former Member
0 Likes
1,384

Hi,

Use this FM SD_DATETIME_DIFFERENCE

Import parameters Value

DATE1 20.05.2007

TIME1 12:00:00

DATE2 23.05.2007

TIME2 12:00:00

Export parameters Value

DATEDIFF 3

TIMEDIFF 0

EARLIEST 1

regards

Shiva

Read only

Former Member
0 Likes
1,384

Hi Rainer,

If you want to add or subtract a number of days from a date.

Use date1 = date1 + 30.

this will add 30 days to the date1.

or use date2 = date2 - 10.

this will give a date 10 days prior to date2.

<b>Reward points, if helpful.</b>

Regards,

Atin

Message was edited by:

Atin Rastogi

Read only

Former Member
0 Likes
1,384

hi rainer,

u can try this fm DAYS_BETWEEN_TWO_DATES.

otherwise write ur own coding for the date calculations as per the requirement.

Regards..

Arun.

Read only

Former Member
0 Likes
1,384

Hi Rainer ,

Please see the FM DATE_IN_FUTURE and RP_CALC_DATE_IN_INTERVAL.

Regards

Arun

Read only

Former Member
0 Likes
1,384

hi,

Check these Fm s

RELATIVE_DATE_CALCULATE

BCA_US_DATES_CALC_DATE

u might have specified date calc based on which scenario??

Thanks,

Deepti

Read only

Former Member
0 Likes
1,384

Hi,

DATE_IN_FUTURE Calculate a date N days in the future.

Regards

Aparna

Read only

Former Member
0 Likes
1,384

i think you are trying to add months and days with a date. If i am not wrong you can do like this... it may work


data : vdate like sy-datum.

vdate = sy-datum.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
  EXPORTING
    months        = '+3'
    olddate       = vdate
 IMPORTING
   NEWDATE       = vdate
          .

vdate = vdate + 5.

write : / vdate.

here i am adding 3months and 5 days with the current date.

vdate must be type d.

regards

shiba dutta

Read only

Former Member
0 Likes
1,384

Hi,

Use the below function module

J_1H_CAL_DATE_IN_INTERVAL

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,384

All of the mentioned FM are in the state 'Not released' and there for will have no support from SAP. As i stated, i dont wanna have there are plenty of them... i', looking for a released one.

Read only

0 Likes
1,384

I don't know of any released date calculation FMs. Unreleased FMs are the meat and potatoes of ABAPERS,

But date arithmetic isn't that difficult. Why don't you just wite your own routine? What exactly are you trying to calculate?

Rob