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: 

How to calculate the days between two dates.

Former Member
0 Kudos

Hi

I need to calculate the amount of days that are between two dates, how can I do that?

Thanks,

Nana

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Nana,

You can define a variable of type I and just subtract both dates.

regards,

John.

12 REPLIES 12

Former Member
0 Kudos

Hi Nana,

You can define a variable of type I and just subtract both dates.

regards,

John.

Former Member
0 Kudos

Nana,

days = date2 - date1.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

Use FM "HR_HK_DIFF_BT_2_DATES".

Former Member
0 Kudos

Use Fm:

SD_DATETIME_DIFFERENCE

to get difference between dates

0 Kudos

Hi,

HR_CALC_YEAR_MONTH_DAY

regards,

srinivasarao.oleti

Former Member
0 Kudos

Hi,

just subtract one date from other.

Hope it helps.

regards,

Shashank

former_member188685
Active Contributor
0 Kudos

Hi,

there is no need of any FM for this, just substract it .

Data: datehigh type sy-datum,
      datelow type sy-datum.

data: diff type i.
datehigh = sy-datum.
datelow = sy-datum - 100.
diff = datehigh - datelow.

write: diff.

Regards

vijay

Former Member
0 Kudos

Hi

Use this FM

DAYS_BETWEEN_TWO_DATES

Former Member
0 Kudos

Hi,

take two variables of date type and with edit mask, remove the slashes in the two variables, subtract them and move to another varible of integer type.

hope it could help you.

regards

-Rakesh

0 Kudos

You can use fm

substract_time_from_date

Regards

0 Kudos

Hi,

use <b>SD_DATETIME_DIFFERENCE</b>

Former Member
0 Kudos

DATA: date1 LIKE sy-datum.

data: DAYS1 TYPE I.

LOOP AT IT_KNA1 INTO WA_KNA1.

DATE1 = WA_KNA1-WADAT_IST.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'

EXPORTING

BEGDA = DATE1

endda = sy-datum

IMPORTING

DAYS = DAYS1.

WA_KNA1-DAYS1 = DAYS1.

MODIFY IT_KNA1 FROM WA_KNA1 TRANSPORTING DAYS1.

CLEAR WA_KNA1.

ENDLOOP.