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

Function module for date difference calculation

Former Member
0 Likes
2,143

hi all,

we have a requirement to calculate the difference date.

for eg: we have a field "datecnt = 4" and "date1 = 14-1-2006(i.e today date)"

the requirement is to subract datecnt from date1 such that the resultant should

be date1-datecnt = 10-11-2006.

is there any readily available function module for the same.

Thanks in Advance,

Kishore Kumar Yerra.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,085

no need of function module for this...this can be done directly...take a vriable v1 like sy-datum.

now, V1 = date1 - datecnt......the value is stored in the V1 field...

V1 = 14/11/2006 - 4...So, V1 will have 10/11/2006.

7 REPLIES 7
Read only

Former Member
0 Likes
1,086

no need of function module for this...this can be done directly...take a vriable v1 like sy-datum.

now, V1 = date1 - datecnt......the value is stored in the V1 field...

V1 = 14/11/2006 - 4...So, V1 will have 10/11/2006.

Read only

Former Member
0 Likes
1,085

Hi,

Use CALCULATE_DATE

Regards,

Raghav

Read only

Former Member
0 Likes
1,085

hi kishore ,

just try this ..

data: v_date like sy-datum,
      v_dateold like sy-datum.

 v_date = sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date            = v_date
    days            = 04
    months          = 00
   SIGNUM           = '-'
    years           = 00
 IMPORTING
   CALC_DATE       = v_dateold.


write:/'Current date',  v_date,
        'Old date   ', v_dateold.

regards,

vijay

Read only

former_member283648
Participant
0 Likes
1,085

Hi,

Try this

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

<b> date = 11/14/2006</b>

<b>days = 4 </b>

months = 0

<b> signum = - </b>

years = 0

IMPORTING

calc_date = result.

Make sure the sign is minus if u want to subtract and plus if u want to add. dont worry about months and years....

Read only

anversha_s
Active Contributor
0 Likes
1,085

hi kishore

use this FM.

data : wa_date type sy-datum.
 
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days = 04 --------------------> give ur required date
months = 0
years = 0
signum = '-'
importing
calc_date = wa_date.
 
write :/ wa_date. -> new minised date

Note

signum = '+' "

signum = '-' "

rgds

Anver

if hlped pls mark points

Read only

Former Member
0 Likes
1,085

Hi

i have given a exaple u can also simply execute and give l3 = <some number>

is is suitable for ur requirement.....

<< u can also use FM , some has posted in this list,, u can also use that>>

data: l1 like sy-datum,

l2 like sy-datum,

l3 type i.

l2 = sy-datum.

l3 = 4.

l1 = l2 - l3.

write:/ l1 dd/mm/yyyy.

out put is: 10.11.2006

Regards,

Ramesh.

Read only

Former Member
0 Likes
1,085

Hi,

Use the function module

HR_HK_DIFF_BT_2_DATES

(HR-HK: Calculate the days, months and years between)

WDKAL_DATE_ADD_FKDAYS

To find out different between dates by considering factory calender.

Regards,

Irfan Hussain

Note: Do reward helpful answers.