Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date 日期范围查询工作不正常_Date_Between - Fatal编程技术网

Date 日期范围查询工作不正常

Date 日期范围查询工作不正常,date,between,Date,Between,我使用下面的代码来过滤带有日期范围的一些结果。它只是给我带来了一些错误的结果。。。就像我用的过滤器是错的一样 代码如下: <html> <head> <title>Classic ASP Search Access Database Demo</title> <style> body {font-family:arial;} table.search {width:200px;} table.recordset {width:600

我使用下面的代码来过滤带有日期范围的一些结果。它只是给我带来了一些错误的结果。。。就像我用的过滤器是错的一样

代码如下:

<html>
<head>
<title>Classic ASP Search Access Database Demo</title>
<style>
 body {font-family:arial;}
 table.search {width:200px;}
table.recordset {width:600px;padding:0px;}
div.recordset {width:618px;height:300px;overflow-y:scroll;border:1px solid black;}
th.recordset {color:white;background:black;padding:2px;}
.search {width:100px;}
.column-1 {width:200px;text-align:left;}
.column-2 {width:200px;text-align:left;}
.column-3 {width:200px;text-align:left;}
.eof {color:red;padding:4px;}
td.recordset {border-bottom: 1px solid silver;}
</style>
</head>
<body>

<%


sSearch1 = Request.Form("search1")
sSearch2 = Request.Form("search2")


%>

<form action="1emvolio.asp" method="post">
<table class="search">
<tr>from
 <td class="search"><input name="search1" type="date" value="<%=sSearch1%>"></td>

</tr>

    <tr>to
 <td class="search"><input name="search2" type="date" value="<%=sSearch2%>"></td>
 <td class="search"><input type="submit" value="Search">
 </tr>
 </table>
 </form>

<h3>Search Results</h3>

<div class="recordset"> 
<table class="recordset" cellspacing="0">
<tr>
 <th class="column-1 recordset">Description 1</th>
 <th class="column-2 recordset">Description 2</th>
 <th class="column-3 recordset">Description 3</th>
</tr>

<%


If sSearch1  <> "" Then




sSearch1 = Trim(Replace(sSearch1,"'","''"))



Set oConnection = Server.CreateObject("ADODB.Connection")

oConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")


Set oRecordset = oConnection.Execute("SELECT * " & _
                                    "FROM emvolio " & _
                                    "WHERE next_date between '" & sSearch1 & "' and '" & sSearch2  "'")



If not oRecordset.EOF Then
 Do While not oRecordset.EOF
%>

<tr>
 <td class="column-1 recordset"><%=oRecordset("chip")%></td>   
 <td class="column-2 recordset"><%=oRecordset("emvolio")%></td>
 <td class="column-3 recordset"><%=oRecordset("next_date")%></td>
</tr>

<%
oRecordset.MoveNext
Loop
Else
%>

<tr>
<td class="eof" colspan="3">No Records</td>
</tr>

<%

end if
end if
response.write(sSearch2)
 response.write(sSearch1)

%>

</table>
</div>
</body>
</html>

经典ASP搜索Access数据库演示
正文{字体系列:arial;}
table.search{宽度:200px;}
table.recordset{宽度:600px;填充:0px;}
div.recordset{width:618px;height:300px;overflow-y:scroll;border:1px纯黑色;}
th.recordset{颜色:白色;背景:黑色;填充:2px;}
.search{width:100px;}
.column-1{宽度:200px;文本对齐:左;}
.column-2{宽度:200px;文本对齐:左;}
.column-3{宽度:200px;文本对齐:左;}
.eof{颜色:红色;填充:4px;}
td.recordset{边框底部:1px纯银;}
从…起
到
搜索结果
说明1
说明2
说明3
没有记录
我认为问题在于“next_date”字段不是日期字段,所以它只读取每个dd/mm/yyyy的第一个数字。 在我使用的access db中,我必须为“next_date”字段使用文本类型,以便使该.asp页面正常工作。当我使用日期类型时,我得到一个错误


请帮助

转换命令可能会起作用

“从emvolio中选择*,其中在“&sSearch1&”和“&sSearch2”之间转换(日期时间,下一个日期,101)”