Link to home
Create AccountLog in
Avatar of curiouswebster
curiouswebsterFlag 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
ASKER CERTIFIED SOLUTION
Avatar of ViaTom
ViaTom
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
try this

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

ASKER

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

newbieweb