‎2011 Jun 16 3:10 AM
Hi ,
Need your guys advice how to compare two date ranges,
As my code snippet show below, those date can not be compare even Date1 is within the range of Date2 logically...
Any guide and insight i appreciate it alot.
Thanks
.
RANGES : date1 FOR p0001-begda,
date2 FOR p0001-endda.
date1-sign = 'I'.
date1-option = 'BT'.
date1-low = '20110101'.
date1-high = '20110808'.
APPEND date1.
date2-sign = 'I'.
date2-option = 'BT'.
date2-low = '20110101'.
date2-high = '20110808'.
APPEND date2.
IF date1 IN date2 .
WRITE:/ 'with in date range'.
SKIP 2.
ENDIF.
.
‎2011 Jun 16 5:04 AM
Hi,
Change the code like this..
if date1-low GE date2-low and date1-low LE date2-high.
WRITE:/ 'with in date range'.
SKIP 2.
else.
write: / 'not in the range'.
endif.
Regards,
Dhina..
‎2011 Jun 16 6:13 AM
For comparing single date:
if date1-LOW GE date2-low AND date1-LOW LE date2-high.
...............
endif.
for comparing range of dates.
if date1-LOW GE date2-low AND date1-HIGH LE date2-high.
...........
endif.
‎2011 Jun 16 5:25 AM
Hi
Please find below FM.
U can give begindate and enddate then u get the differences.
HR_99S_INTERVAL_BETWEEN_DATES
Thanks$ Regards.
MURALII
‎2011 Jun 16 5:46 AM
Hi,
I think only single values can be compared with ranges and not the entire range.
Instead loop at the first range and check if the dates lies in between the other range.
loop at date1.
if date1-low in date2 and date1-high in date2.
*your coding.
else.
*coding
endif.
endloop.
Regards,
Srini.
‎2011 Jun 16 5:53 AM
try the following
RANGES : date1 FOR p0001-begda,
date2 FOR p0001-endda.
date1-sign = 'I'.
date1-option = 'BT'.
date1-low = '20110101'.
date1-high = '20110808'.
APPEND date1.
date2-sign = 'I'.
date2-option = 'BT'.
date2-low = '20110101'.
date2-high = '20110808'.
APPEND date2.
use any one
if date1-low GE date2-low and date1-high LE date2-high.
or
if date1-low in date2-low and date1-high in date2-high.
WRITE:/ 'with in date range'.
else.
write: / 'out of date range'.
ENDIF.
or
use this fm to calculate the date range HR_99S_INTERVAL_BETWEEN_DATES
here if the result is greater that the actual range then write: out of date range
else if the result is less than or equal to actual range then write: with in range.
NOTE: for this second method actual range refers to the difference of dates calculated by you manually.
So i suggest try the first code.
hope it solves your purpose.
thanks and regards,
koolspy.