[thelist] ASP: SQL Select records within 1 week.

Ken Schaefer ken at adOpenStatic.com
Mon Apr 12 05:37:29 CDT 2004


If you are using Access, then you can access VBA functions from within
Access. No need to concantenate a string:

strSQL = _
    "SELECT TOP 5 * " & _
    "FROM  t_cameraphone " & _
    "WHERE dDate > DateAdd("d", -7, Date()) " & _
    "ORDER BY tVIEWS DESC"


If you really want to calculate a value in ASP, then pass that to Access, I
suggest you Response.Write() your SQL statement to the screen. Cut-n-paste
that into Access (Query -> New Query -> SQL View), and run it. Access will
tell you where the error is occuring.

Cheers
Ken

----- Original Message ----- 
From: "Christian Anderson" <lists at photokyo.com>
To: <thelist at lists.evolt.org>
Sent: Monday, April 12, 2004 8:30 PM
Subject: [thelist] ASP: SQL Select records within 1 week.


: Hi,
:
: I'm trying to select the most viewed records from my database over the
last
: week, but am running into a problem. Here is the string that I am using:
:
: SQL=("SELECT TOP 5 * FROM t_cameraphone WHERE dDATE > '" &
: DateAdd("D",-7,Now()) & "' ORDER BY tVIEWS desc;")
:
: The DateAdd function is going back 7 days from now, and I think this
SHOULD
: give me the records that are newer than that date... but I get the
following
: error:
:
: Microsoft JET Database Engine error '80040e07'
:
: Data type mismatch in criteria expression.
:
: Any ideas how to make that statement work? I tried taking out the ' around
: the dateadd thing, but that didnt work...
:
:
: Christian Anderson
: Niseko Hirafu, Hokkaido, Japan
: http://www.photokyo.com <http://www.photokyo.com/>
:
:
: -- 
: * * Please support the community that supports you.  * *
: http://evolt.org/help_support_evolt/
:
: For unsubscribe and other options, including the Tip Harvester
: and archives of thelist go to: http://lists.evolt.org
: Workers of the Web, evolt !
:



More information about the thelist mailing list