|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
[ASP]时间段查询(已解决)
做一个查询某时间段内所有记录的程序,以下这段代码(有颜色部分)是否有不妥的地方,为何查询不出这个时间段内的所有记录?
比如开始时间为2006-7-1,结束时间为2006-7-10,查出的记录就只有1号和10号的,其他的就显示不出来```
请教``
<%
Dim whereClause
Dim MM_whereConst
hasSQLWhereClause=false
whereClause=""
MM_whereConst = " "
[color=#0033CC]
Set fieldValue = Request.QueryString("srartdate")'开始时间
fieldValue1 = Request.QueryString("enddate")'结束时间
If Request.QueryString("srartdate") <> "" and Request.QueryString("enddate") <> "" Then
whereClause=whereClause & "rtrim(ltrim(Ucase(SaDate))) between rtrim(ltrim(Ucase(#" & fieldValue & "#))) and rtrim(ltrim(Ucase(#" & fieldValue1 & "#)))"
end if
[/color]
If whereClause <> "" Then
MM_whereConst = "WHERE"
End If
Dim RecordSet1
Dim RecordSet1_numRows
Set RecordSet1 = Server.CreateObject("ADODB.Recordset")
RecordSet1.ActiveConnection = MM_conn_STRING
RecordSet1.Source = "SELECT Ice_Surrogate.SuName, Ice_Product.PrDenomination, Ice_ProductSpec.PsName, Ice_Sales.* FROM (Ice_Surrogate INNER JOIN Ice_Sales ON Ice_Surrogate.SuID = Ice_Sales.reSuID) INNER JOIN (Ice_Product INNER JOIN Ice_ProductSpec ON Ice_Product.PrID = Ice_ProductSpec.rePrID) ON Ice_Sales.rePsID = Ice_ProductSpec.PsID " & MM_whereConst & " " & whereClause & " order by SaDate desc"
RecordSet1.CursorType = 0
RecordSet1.CursorLocation = 2
RecordSet1.LockType = 1
RecordSet1.Open()
RecordSet1_numRows = 0
%>
|
[ASP]时间段查询
SaDate为数据库中的时间字段,格式为YYYY-MM-DD,月或日为一位数时显示为YYYY-M-D,不知道是否有关系? |
自己搞定```
whereClause=whereClause & "SaDate between #" & fieldValue & "# and #" & fieldValue1 & "#" |
|