Corrected formatting of datetime columns in queries