Fixed timestamp comparison in sql query.