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

error with DAYS_BETWEEN_TWO_DATES FM

Former Member
1,487

I am using the FM DAYS_BETWEEN_TWO_DATES, however it is not working as expected....

My code looks like this:


          CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
            EXPORTING
              i_datum_bis             = lw_booked-enddt
              i_datum_von             = lw_booked-strdt
              i_kz_incl_bis           = '1'
            IMPORTING
              e_tage                  = lw_booked-duration
            EXCEPTIONS
              days_method_not_defined = 1
              OTHERS                  = 2.

the data looks like this once converted using this FM (start date / end date / duration)...

15.10.2011 17.10.2011 3.00

03.10.2011 04.10.2011 2.00

13.10.2011 15.10.2011 3.00

06.10.2011 09.10.2011 4.00

22.10.2011 24.10.2011 3.00

20.10.2011 21.10.2011 2.00

22.10.2011 24.10.2011 3.00

28.10.2011 01.11.2011 4.00

all the entries, but the last entry are correct using this FM!

the 28.10.2011 - 01.11.2011 is 5 days - not 4... if i can't rely on standard SAP FM.. what can i use instead???

2 REPLIES 2
Read only

Former Member
0 Likes
731

What's wrong with a line of code? Write a line of code that says essentially

duration = enddate - startdate.  or if you want inclusive:
duration = ( enddate - startdate )  + 1.

Guess I'm biased, but I don't understand why programmers search for and find obscure function modules, code for those and struggle with the results instead of inserting a single line of code! Maybe I'm obsolete...

Read only

Former Member
731

Fixed!

needed to set I_SZBMETH = SPACE