To compare two dates d1 and d2 which have the date pattern YYMMDD, you can use the following code:
DAYS (d1, 'YYMMDD', w) < DAYS(d2, 'YYMMDD', w)