I'm trying to compare a stored date (Datetime) to the current system date. I'm using the following query:
SELECT *
FROM Table
WHERE (StoredDate > Date())
and it gives me the correct result. But it also states there is an
SQL syntax error in the WHERE-Clause near ")". Analyzing of query string not possible.
The time format I set up in Access is 'General Date'. It works fine if I compare the date with an integer.
Can anyone see the problem?
Cheers
Kruspe
if you don't supply a time along with a date, SQL Server automatically assumes midnight (there are no independant Date and Time datatypes up to SQL Server 2000, there are supossed to be ones in SQL Server 2005). Look up the DATETIME datatype in SQL Server Books Online.
If you want all records greater than 1/1/2005, try:
Select *
FROM tablename
WHERE datefield >= '1/1/2005 23:59:59.000'
or '1/1/2005 23:59:59.999' or whatever works for you.
(do a Select getdate() to see the current time in this format).
Also, do a search on this site for DATETIME. I believe there are several articles on the subject.