Updated sql queries for date format