Date Comparison

M

Me

In Access database I have a table linked to sql server database. I would like
to do the date comparison like

select ... from <tablename> where podate > 'fromdate' and podate < 'todate'

in this query fromdate could be like '1/1/1997' and todate like '31/12/2001'

when I run the query, I get error data type mismatch.

Can someone help me in writing the correct query?

Thank you,
-Me
 
T

Tom Ellison

Dear You:

Please try something once, very simple.

Enter all dates strictly MM/DD/YYYY. Do not enter 31/12/2001 but
12/31/2001.

Does that make a difference?

Next, if that isn't enough, use "CDate() around the entered dates.

A date like 1/3/2006 would be ambiguous. Is it January 3 or March 1? To
avoid ambiguity like this, it will use strictly MM/DD/YYYY to interpret
entered dates. 31/12/2001 is therefore not a date at all.

Tom Ellison
 
T

Tom Ellison

Dear John:

Yes, probably so. Not if it's for MSDE (where I uusually work, and why I
didn't catch that, especially as Me used single quotes, which looks all the
more like MSDE), but then most questions here are for Jet.

My mistake!

Tom Ellison
 

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