How refer to current date in Excel SQL query?

R

Ronald S. Cook

I'm trying to use Microsoft Query within Excel to write a SQL query against
a data set.

SELECT e.EVENTNAME, e.EVENTDATE
FROM EVENT e
WHERE (e.EVENTDATE >= DATE()
ORDER BY e.EVENTDATE

In the above, DATE() is not correct to get the current system date. I tried
DATE, NOW, NOW(), GETDATE, GETDATE(), TODAY, TODAY().. now of which worked.

Can someoine please tell me the correct syntax?

Thanks!
Ron
 
W

Will.Cairns

Ronald, Here is the way I handle the Date issue..

strToday = DateValue(Now())

SQL = Select * from MyTable where DateField < strToday
 
R

Ronald S. Cook

But what I'm writing is write in the SQL query window so I can't establish
variables, etc.

I tried the below but it didn't work either:
 
W

Will.Cairns

May just be the position/use of your parenthesis.. I tried the
following clause in MS Access and then in the MS Query window and both
gave me the same result..

WHERE ((TblTraffic.RPT_DATE)<Now())

HTH,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top