Date Comparison

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Dear Tom,
I only pointed out that IF your solution didn't work, then try ...

I was unsure if the poster was using MSDE or JET or ??? I've just seen so
many posts where the wrong (or no) delimiter has been used that this is
often the first thing I see. Your posting has once again reminded me to be
careful in assuming that the poster is using JET or an ODBC connection to
some other data engine.
 
Dear John,

Now look here. I'm not going to argue with you interminably. It was my
mistake, and that's all there is to it. I'm not going to put up with you
trying to take credit for my mistakes! : )

Assuming all posts here are for Jet is pretty safe!

Tom
 
Back
Top