fixed date problem with sql statement