Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Data type mismatch in criteria expression

Author  Topic 

samson
Starting Member

1 Post

Posted - 2004-02-14 : 10:23:40
Hi all,

How can I select only the last 93 days of itemns from an Access database ?

Our website currently has a news feed from a local SQL 7.0 database. The last 93 days of news are selected from the database and displayed on index.asp. This works fine but we need to convert to Access.

In testing, we have converted the SQL database into Access and all the news functionality works fine except that we can no longer specify to display only the last 93 days. We must remove the date specific section to get the page to display.
If we leave the date specific section in the asp page does not display properly and we get the error

Data type mismatch in criteria expression.

Below are the 2 different database selection bits. One is the SQL 7.0 string that works and displays only the last 93 days of items. The second is the Access string that works but displays all items.

Thanks in advance

SQL 7.0 - works fine and selects last 93 days of News

<%
Dim objRS, strSQL
Set objRS = Server.CreateObject("ADODB.Recordset")

' get the items
Dim DateToCompare
DateToCompare = year(date - 93) & "/" & month(date - 93) & "/" & day(date - 93)

strSQL = "SELECT * " &_
"FROM News " &_
"WHERE date > '" & DateToCompare & "'"&_
"ORDER BY date desc;"
objRS.Open strSQL, objConn

if objRS.BOF = True then

else
Do While Not objRS.EOF
%>


ACCESS - WORKS FINE BUT GETS ALL NEWS ITEMS

<%
Dim objRS, strSQL
Set objRS = Server.CreateObject("ADODB.Recordset")

' get the items
strSQL = "SELECT * " &_
"FROM News " &_
"ORDER BY date desc;"
objRS.Open strSQL, objConn

if objRS.BOF = True then

else
Do While Not objRS.EOF
%>





Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2004-02-14 : 14:44:36
"FROM News " &_
"WHERE [date] > date()-93 " &_
"ORDER BY [date] desc;"
Go to Top of Page
   

- Advertisement -