Access, SQL: how to select dates older than

Hi X-perts,

I need to select records with the date field older than a certain date;

"SELECT [MSCI] FROM EFdb WHERE [dates] >= 9/1/2006"

It returns ALL the records and doesn't filter the dates

What is the correct syntax for this?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try quoting the date. 9/1/2006 will probably be evaluated as a fractional number instead of a date.
Quotes are not the literal date delimiter ... you should use the octothorpes (#) ...

"SELECT [MSCI] FROM EFdb WHERE [dates] >= #9/1/2006#"

A note about the octothorpes delimiters, it will force Jet/Access to assume US date format if the date is in an ambiguous format, so, when creating my SQL statements via code, I will use an unabiguous formation ....

"SELECT [MSCI] FROM EFdb WHERE [dates] >= #2006-09-01#"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony PerkinsCommented:
This is how you do it in T-SQL:
"SELECT [MSCI] FROM EFdb WHERE [dates] >= '20060901"

Or more appropriately (assuming US mdy format):
"SELECT [MSCI] FROM EFdb WHERE [dates] >= CONVERT(datetime, '9/1/2006', 101)"
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Anthony PerkinsCommented:
P.S. If this is not an MS SQL Server question, please refrain from adding the MS SQL Server Zone.
Good follow up acperkins ... in T-SQL the date delimiter is the single quote .... so ... I persoally still stick with International format ...

SELECT [MSCI] FROM EFdb WHERE [dates] >= '2006-09-06'
>>Quotes are not the literal date delimiter ... you should use the octothorpes (#) ...

Since the question was in the SQL Server Zone I assumed it was a SQL Server query. I did not notice Access in the zones when I answered.
andy7789Author Commented:
Thank you all! Sorry for the confusion with the zones  :)
>> Since the question was in the SQL Server Zone I assumed it was a SQL Server query <<

LOL ... I looked at the title and saw "Access" ... I didn't even see the Zone! ... :-S
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.