Properly handle date ranges