Pega under the covers manages dates and date/times as Strings. The conventions that Pega uses for recording the date-only (yyyyMMdd, as you suggest) and date/time values are such that you should be able to basic String comparison and still determine whether one is before the other.
As such, if XX and YY are both Pega Date-only fields, if XX -is less than- YY as a String comparison, then XX is before YY.
If you are triggering this from a When rule, seek out the "[first value] [relation] [second value]" condition on the Advanced tab.
If you are triggering this from a Data Transform rule (or similar) and need the function, go with @ExpressionEvaluators.compareTwoValues(left, comparator, right) ... where comparator can be "<", "<=", "=", etc. Check the Function rule implementation for all the comparators that it supports.
The scenario to watch out for where the string comparison is not reliable is if one is a date/time and the other is date/only.
You would need the Functions from the Date/Time library if you are doing timezone conversion or "date arithmetic" (e.g. what is the date 7 days ahead of XX?)