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 arithmetic...have ur points..

Former Member
0 Likes
1,072

Hi all,

I want to do arithmetic operations on date type fields..

like i want to add 5 days to current date...like this..

Pleas help me...

& have ur points..

Regards,

pradeep

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
904

hi check this code,

data : days type i,fdate type sy-datum, ldate type sy-datum.

fdate = sy-datum. " todays date

ldate = fdate + 2. " add 2 days

days = ldate - fdate. " days will be 2.

do modifications according to ur requirement

5 REPLIES 5
Read only

Former Member
0 Likes
904

Hi,

check the function module:

RP_CALC_DATE_IN_INTERVAL

regards,

Navneeth K.

Read only

kiran_k8
Active Contributor
0 Likes
904

Pradeep,

Try this function module

DATE_IN_FUTURE ? takes number of days and date - gives future date in user format and system format

K.Kiran.

Read only

Former Member
0 Likes
905

hi check this code,

data : days type i,fdate type sy-datum, ldate type sy-datum.

fdate = sy-datum. " todays date

ldate = fdate + 2. " add 2 days

days = ldate - fdate. " days will be 2.

do modifications according to ur requirement

Read only

Former Member
0 Likes
904

Hi Pradeep,

If you want to add 5 working days to current date then you need to convert the date to factory date first passing country id and the date

DATE_CONVERT_TO_FACTORYDATE

then add 5 to the returned number and convert the value to date type using

FACTORYDATE_CONVERT_TO_DATE

Award points if this is helpful.

Regards,

Ravi G

Read only

varma_narayana
Active Contributor
0 Likes
904

Hi Pradeep...

Find some of the useful date operations here.

Data : v_date1 like sy-datum.

Data : v_date2 like sy-datum.

Data : v_diff type i.

**Assigning date variables

v_date1 = sy-datum.

v_date2 = sy-datum.

**Extract the individual parts of date

v_date1+6(2) = '01' . "set the Day as the First day of the month

write:/ v_date1.

**Adding no of days.

v_date2 = v_date2 + 5.

write: v_date2.

**Subtracting two date fields

v_diff = v_date2 - v_date1.

write:/ v_diff.

Additionally you can find various FMs to process dates.

Some of them can be found in Function group SCAL.

<b>REWARD POINTS IF HELPFUL.</b>