Avatar of curiouswebster
curiouswebster
Flag for United States of America asked on

Trouble with WHERE using OleDbCommand and DataTime

I have an Access database with a text column called CreationDate. The format of the field is '2/2/2010', for example. No leading zeroes for month or day fields.

This WHERE does not work. There are no exceptions, but valid data does not get retrieved.

WHERE Format(CreationDate, 'MM/dd/yyyy') >= '2/18/2010' AND Format(CreationDate, 'MM/dd/yyyy') <= '2/20/2010'

Any suggestions? There are no records returned by this query, even though I can see there are multiple. This problem may force me to dig deep and find a much bigger work around., which I really do not want to do.

Thanks for any help.
newbieweb
Microsoft Access.NET ProgrammingSQL

Avatar of undefined
Last Comment
curiouswebster

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ViaTom

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
HainKurt

try this

WHERE cdate(CreationDate) >= cdate('2/18/2010') AND cdate(CreationDate) <= cdate('2/20/2010')
curiouswebster

ASKER
Thanks! It works great. I did not test the second alternative...

newbieweb
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23