Skip to content
Advertisement

Simple DateTime sql query

How do I query DateTime database field within a certain range?

I am using SQL SERVER 2005

Error code below

Note that I need to get rows within a certain time range. Example, 10 mins time range.

Currently SQL return with Incorrect syntax near ’12’.”

Advertisement

Answer

You missed single quote sign:

Also, it is recommended to use ISO8601 format YYYY-MM-DDThh:mm:ss.nnn[ Z ], as this one will not depend on your server’s local culture.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement