modify query to fix where clause error and date error
modify query remove rogue apostrophe and to add a space