2005 Nov 25 11:57 AM
Hi ,
Can somebody pls help me with the function module to get the difference between two dates?
I need to find the difference value and delete records if >1.
Thanks in advance.
Regds,
Leeza.
Hi ,
Can somebody pls help me with the function module to get the difference between two dates?
I need to find the difference value and delete records if >1.
Thanks in advance.
Regds,
Leeza.
2005 Nov 25 11:59 AM
2005 Nov 25 12:06 PM
Thnx for the help Ashish.It was indeed very helpful info.
But I dont have the time parameter.
Any other FM to help out with input as only the date values and get the difference.
Regds,
Leeza.
2005 Nov 25 12:09 PM
Leeza, it's ok if u don't have time, just hardcode 240000 in both the time fields.
Ashish
2005 Nov 25 12:11 PM
Leeza,
Try <b>DAYS_BETWEEN_TWO_DATES
MONTHS_BETWEEN_TWO_DATES</b>.
Thanks
Kam
2005 Nov 25 12:09 PM
Hi thif FM needs time input also.
SD_DATETIME_DIFFERENCE
regards
vijay
2005 Nov 25 12:09 PM
Hi Leeza,
This FM.
HR_99S_INTERVAL_BETWEEN_DATES
The above FM is comprehensive.
it will give much information.
difference in
-
days
weeks
months
and years
-
Regards,
Amit M.
Message was edited by: Amit Mittal
Message was edited by: Amit Mittal
2005 Nov 25 12:34 PM
Thanks Kam...
MONTHS_BETWEEN_TWO_DATES is not retrieving any value when I specify only the dates.
What should be the 'I_KZ_INCL_BIS' value be?
2005 Nov 25 1:19 PM
Leeza,
When I tested the FM in my Program, it is <b>working</b>!!!!!
Note that the Two Input Dates are to be in the format of <b>DATS</b> type (Eg: <b>vimimv-dmibeg</b>).
U can want the Day which u have specified in the parameter I_DATUM_BIS (eg: 20050101) to be included for
the calculation , then put X in the parameter I_KZ_INCL_BIS.
Sample Code :
report zkam01.
data:
<b>sav_nlaufz like rf60v-nlaufz,
date1 type vimimv-dmibeg,
date2 type vimimv-dmiend.</b>
date1 = '20050101'.
date2 = '20051001'.
call function 'MONTHS_BETWEEN_TWO_DATES'
exporting
i_datum_von = date1
i_datum_bis = date2
i_kz_incl_bis = 'X'
importing
e_monate = sav_nlaufz.
write:
date1,
/ date2,
/ sav_nlaufz.
Please allot points if the problem is solved.
Thanks
Kam
Message was edited by: Kam
2005 Nov 25 1:10 PM
Hi,
You dont need function module to get difference between two dates. You can simply subtract and get days.
See the following example,
DATA: gv_date1 LIKE sy-datum,
gv_date2 LIKE sy-datum,
gv_days TYPE i.
gv_date1 = '20051125'.
gv_date2 = '20051124'.
IF gv_date1 GE gv_date2.
gv_days = gv_date1 - gv_date2.
ELSE.
gv_days = gv_date2 - gv_date1.
ENDIF.
WRITE gv_days.
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni
2005 Nov 25 2:42 PM
Hi,
Sample code for the function module you want.
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.
Regards,
Sailaja.
Dont forget to reward points, if answer helps you.
2005 Nov 25 4:05 PM
Hi Leeza,
You don't need a function module to do that. Here is a simple logic.
LOOP AT itab.
v_number_of_days = itab-date2 - itab-date1.
IF v_number_of_days > 1.
DELETE itab.
ELSE.
*-- Do something else.
ENDIF.
ENDLOOP.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |