11-03-2007 8:55 AM
Hi
I need to calculate the date diff in daya b/w two dates,but the result should come in -ive sign if exist there any b/w the dates.
so kindly please help in ths regards,or kingly pass on the code if there.
I had used the code : o_date = ( date1 - date2 ).
The result is comiing fine,but there exit any FM it will be easy to manuplate the things fast.
Moreover,the Diff for dates is coming in -ive but the -ive sign is coming like : 21 -.
I want it should come: -21.
Please help me fast,if u got my prob??
Regards.
Vipin.
11-03-2007 9:01 AM
FM is HR_HK_DIFF_BT_2_DATES
but if ur using some other functionality and getting the output
just modify the output as below
search '-' in o_date .
if sy-subrc = 0.
replace all occurances of '-' in o_date with spaces.
concatenate '-' o_date into o_date.
tc
saji
11-03-2007 9:01 AM
FM is HR_HK_DIFF_BT_2_DATES
but if ur using some other functionality and getting the output
just modify the output as below
search '-' in o_date .
if sy-subrc = 0.
replace all occurances of '-' in o_date with spaces.
concatenate '-' o_date into o_date.
tc
saji
11-03-2007 9:14 AM
hi
thanks for help.
but its displaying ... : Specificaton 'FOR....' is missing
11-04-2007 5:22 AM
Hi
I hope you can help me in this.
Well to calc the day diff o_date, i had used it as type p.now when i m using the code, told by you,its giving me error to use type c,n,t,d.which can bea prob for me.when i changed it to c or n type,its displaying nos. of zeros in fornt of it & how to remove them? secondly again than i have to pass this value (c or n type) to p type coz in my code i had used it as counter to calc no of days for some other purpose.is it possible to change it to p type again than.plz help me...
regards
vipin
11-03-2007 9:11 AM
check this sample code.
data : date1 like sy-datum,
date2 like sy-datum,
diff(10) type c.
date1 = '20071003'.
date2 = '20071104'.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = date1
I_DATUM_VON = date2
* I_KZ_EXCL_VON = '0'
* I_KZ_INCL_BIS = '0'
* I_KZ_ULT_BIS = ' '
* I_KZ_ULT_VON = ' '
* I_STGMETH = '0'
* I_SZBMETH = '1'
IMPORTING
E_TAGE = diff
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
VALUE = diff
.
write : / diff.
regards
shiba dutta