sql query to fetch records based on date