‎2007 Mar 14 4:10 PM
Hi,
I have fields of length 8 containing the date. How do i find that the date given is between another two dates of the same type?
‎2007 Mar 14 4:12 PM
Hi,
Build a range..
RANGES: R_DATE FOR SY-DATUM.
R_DATE-SIGN = 'I'.
R_DATE-OPTION = <b>'BT'</b>.
R_DATE-LOW = SY-DATUM - 10.
R_DATE-LOW = SY-DATUM + 10.
APPEND R_DATE.
IF SY-DATUM IN R_DATE.
WRITE: / 'DATE IS WITHIN THE RANGE'.
ENDIF.
Thanks,
Naren
‎2007 Mar 14 4:13 PM
If you have the dates in YYYYMMDD formats, assign them to TYPE D fields OR LIKE SY-DATUM fields. Then you can simply compare like this
IF your_date < to_date AND your_date > from_date.
ENDIF.
‎2007 Mar 14 4:13 PM
you could do either
date1 type dats
date2 type dats
date3 type dats
if date1 ge date 2 and
date1 le date 3.
.....
endif
‎2007 Mar 14 4:13 PM
REPORT YCHATEST.
DATA : V_DATE(8) VALUE '20060314',
V_DATE1(8) VALUE '20060310',
V_DATE2(8) VALUE '20060320'.
IF V_DATE LT V_DATE2 AND
V_DATE GT V_DATE1.
WRITE : / 'Date between 2 dates'.
ENDIF.
‎2007 Mar 14 4:38 PM
Hi,
I did try all that you said. It isn't working. When the data is entered, the format is ddmmyyyy. So, when i give a condition to check if the given date is b/w 2 others, it is being treated as numbers. For example, 01022012(1st Feb 2012) should be outside the range of 01012011(1st Jan 2011) and 31122011(31st Dec 2011). But the check shows that the date is in between these dates.
‎2007 Mar 14 4:52 PM
@ Chandrashekar: Hey thanx buddy...your method works...will try in my pgm n tell u the result...
@all: thanx everyone for your suggestions
‎2007 Mar 14 4:52 PM
Hi,
Convert the date format from DDMMYYYY to the internal format YYYYMMDD
V_DDMMYYYY = '14032007'.
CONCATENATE V_DDMMYYYY4(4) V_DDMMYYYY2(2)
V_DDMMYYYY(2) INTO V_DATE.
Then build a range and converted date and then do the comparison..
Thanks,
Naren