07-06-2006 4:05 AM
Hi guys,
I have an internal table with 3 fields. One of the fields is holding date.
I need to compare these dates in the internal table to find the latest.
Do you know any function module that can compare dates to find the latest in one internal table?
Thanks
William Wilstroth
07-06-2006 4:09 AM
Why don't simply SORT the internal table by DATE DESCENDING and take the first row.
SORT ITAB BY DATE_COLUMN DESCENDING.
READ TABLE ITAB INDEX 1
Regards,
Ravi
07-06-2006 4:19 AM
Sort the table using below command
sort i_table by date_field decending.
read i_table index 1.
07-06-2006 4:29 AM
Hi William,
U can use this sample of code to get the latest among the three dates of an internal table.
DATA : BEGIN OF itab OCCURS 0,
date1 TYPE sy-datum,
date2 TYPE sy-datum,
date3 TYPE sy-datum,
END OF itab.
DATA : l_date TYPE sy-datum.
itab-date1 = '20061228'.
itab-date2 = '20061201'.
itab-date3 = '20061231'.
APPEND itab.
itab-date1 = '20060728'.
itab-date2 = '20060601'.
itab-date3 = '20060531'.
APPEND itab.
LOOP AT itab.
IF itab-date1 >= itab-date2.
IF itab-date1 >= itab-date3.
l_date = itab-date1.
ELSE.
l_date = itab-date3.
ENDIF.
ELSEIF itab-date2 >= itab-date3.
l_date = itab-date2.
ELSE.
l_date = itab-date3.
ENDIF.
WRITE : / l_date, sy-tabix.
ENDLOOP.
Hope it will help u in some way.
07-06-2006 6:06 AM
HI
GOOD
I DONT THINK THERE IS ANY DATE FUNCTION MODULE WHO WILL COMPARE DATE IN A INTERNAL TABLE AND GIVE YOU THE RESULT.
TRY WITH
RH_GET_DATE_DAYNAME return the day based on the date provied
THANKS
MRUTYUN
07-06-2006 6:29 AM
hi william,
u can use TIMESTAMP functionality for sort ur internal table , it sort bye date as well as timealso .
i hope it will help u.
with regard
chetan vishnoi