fix date issue in query