I have two dates; date1 = 2021-01-14T00:00:00-05:00 and date2 = 2021-01-17T00:00:00-05:00. is there a good way to compare them in xquery
Yes, you can simply do
xs:dateTime('2021-01-14T00:00:00-05:00') < xs:dateTime('2021-01-17T00:00:00-05:00')