Fix bugs in dates comparison.