Fix date vs datetime range problems