Application Development 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: 

can any one tell me difference between 2 dates in days

Former Member
0 Kudos

hi guys,

can any one tell me the difference between 2 dates in days

for eg: input 20.12.2006 and 06.11.2006 will be 34.

thanks in advance for you answers

Regards,

Anil kumar P

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Anil,

Check this code for u r requirement

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.

6 REPLIES 6

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

data : v1 type i.

v1 = d1 - d2.

write v1.

If d1 and d2 hold date values of type sy-datum.

0 Kudos

use Fm - DAYS_BETWEEN_TWO_DATES

amit

Former Member
0 Kudos

if two variables are of type d you can do by simple subtraction.

d3 = d2 - d1.

d3 also type i.

other ways you have to use fm like DAYS_BETWEEN_TWO_DATES

regards

shiba dutta

Message was edited by:

SHIBA DUTTA

Former Member
0 Kudos

Hi

U try this FM

SD_DATETIME_DIFFERENCE

u set the time as 12 both tme fields

hope this will help u

Thanks

Shiva

Former Member
0 Kudos

Hi Anil,

Check this code for u r requirement

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.

Former Member
0 Kudos

Hi,

Use the FM:

<b>SD_DATETIME_DIFFERENCE</b>

Give the difference in Days and Time for 2 dates

Hope this helps.

Reward if helpful.

Regards,

Sipra