fixed bug where query checking wrong date