I have been working on a program designed to read information from an Access database and display it on the screen. As my main development box doesn't have a copy of Access on it, I copied the data over to a PostgreSQL database and attempted to work from that. Now, having gotten the program working there, I was attempting to set it back up to receive data from the Access database.

My first SQL statement is throwing an error. The statement is "select distinct(deptCD) from sessionD where custID = '2' and dt >= '2004-1-01' and dt < '2004-3-31'". The error I am getting is 'Data type mismatch in criteria expression'. Would anyone please be willing to explain to me what it is I'm doing wrong with my statement?

It all depends on the datatypes you have set in the database table, but I see two issues in your statement.

1. INT types do not have ' around them
2. DATES are surrounded by #

Try this:

select distinct(deptCD) from sessionD where custID = 2 and dt >= #2004-1-01# and dt < #2004-3-31#
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.