var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: DateTime Query Question
I wrote an SQL sentence but it generates "Syntax error (missing operator) in query expression 'MyDate=20.04.2004 10:25:22'" error message.
What is the error on this SQL sentence?
"SELECT * FROM SomeTable WHERE MyDate=" + DateTime.Now + ""
Thanks for any reply...
Note: DateTime.Now is a C# code which returns the current date in 20.04.2004 10:24:56 format.
Remember to put # before and after a date field variable, ' before and after a text field variable, and nothing before and after a number field variable.
Firstly, thanks for your reply. I placed # before and after my date filed and now I got the following error:
"Syntax error in date in query expression 'MyDate=#20.04.2004 13:22:46#'"
My new SQL sentence is now this:
"SELECT * FROM SomeTable WHERE MyDate=#" + DateTime.Now + "#"
What is the problem in this SQL sentence?
Perhaps try something like this which just worked for me with different table and field names:
"SELECT * FROM SomeTable WHERE MyDate=Date();"
"SELECT * FROM SomeTable WHERE MyDate=Now();"
But of course the latter would only find a record with the same date/time as the current second. So may want to use min and max dates if really storing a date/time instead of just a date.
And of course be sure that your date/time field is really a date/time field and not a number field or text field.