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

what is the function module to difference between two date

Former Member
0 Likes
15,303

Hi,

I need to know what is the function module that is used to find the difference between two dates.

Regards,

Clara

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,809

Hi clara/cheli!

Use Function module SD_DATETIME_DIFFERENCE to get the result.

G.Prasanna Kumar

reward points if helpful

Message was edited by: Praneeth kumar

6 REPLIES 6
Read only

Former Member
0 Likes
7,809

REPORT ZDATEDIFF.

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

  • I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

Read only

Former Member
0 Likes
7,810

Hi clara/cheli!

Use Function module SD_DATETIME_DIFFERENCE to get the result.

G.Prasanna Kumar

reward points if helpful

Message was edited by: Praneeth kumar

Read only

Former Member
0 Likes
7,809

hi ,

try these fms..

SD_DATETIME_DIFFERENCE

DAYS_BETWEEN_TWO_DATES

MONTHS_BETWEEN_TWO_DATES..

<b>reward if useful..</b>

Read only

Former Member
0 Likes
7,809

hi,

For finding the difference between two dates, there is no need of function module. We can get it by just simple subtraction.

data:

date1 like sy-datum,

date2 like sy-datum.

v_diff = date1 - date2.

Please find the link

Here you can find the function modules with examples.

Regards,

Sailaja.

Read only

Former Member
0 Likes
7,809

hi Clara,

why do you need FM for that..

data: date1 type sy-datum,
      date2  type sy-datum.

data: diff type i.

diff = date1 - date2.

Regards

vijay

Read only

Former Member
0 Likes
7,809

Hi,

SD_DATETIME_DIFFERENCE- to find the difference between two dates.

Regards,

Varma