‎2007 Jan 12 6:26 AM
Hi,
I am having 2 dates in the format YYYYMMDD. How can i compare both the dates. The date1 should be less than date2. Can u tell the FM to compare the dates. Urgent.
Thanks.
‎2007 Jan 12 6:27 AM
Hi,
Check this sample..
DATA: V_DATE1 TYPE SYDATUM.
DATA: V_DATE2 TYPE SYDATUM.
the internal date format is YYYYMMDD..which is of type D.
V_DATE1 = SY-DATUM.
V_DATE2 = SY-DATUM - 1.
Comparison
IF V_DATE1 < V_DATE2.
WRITE: / 'V_DATE1 IS LESSER'.
ELSE.
WRITE: / 'V_DATE2 IS LESSER'.
ENDIF.
Thanks,
Naren
‎2007 Jan 12 6:30 AM
data: date1 type d value '20060101',
date2 type d value '20060102'.
if date1 LT date2.
write date1.
else.
write date2.
endif.
‎2007 Jan 12 6:31 AM
Naren's example is simple and best suitable.
Just incase you need a FM: <b>FIMA_DATE_COMPARE</b> can help you.
Just the dates input is enough. It gives if first date is LT or EQ or GT second date...
Regards
Eswar
‎2007 Jan 12 6:46 AM
Hi
use this FM
<b>C14B_DATE_TIME_COMPARE</b>
enter the dates and it will generate a flag = 'X' if the first date is less than second
Hope this will help you a lot
Thanks
Shiva