ASP SQL 按时间查询问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 00:51:46
时间格式是 2007-8-7 15:15:46 如果按2007-8-7查询我应该怎么样写?

case ""
rs.open "select * from [card] where (chongtime between 2007-08-07 and 2007-08-08) and ok=1 order by chongtime desc",conn,1,1

测试的时候查不到数据问题在哪里?

我需要用between #"&day1&"# and #"&day2&"#"
的方式来写..请帮忙 100分送上..
要是有完整的相关源码最好了...
要的是源码啊

我测试通过了

BeginDay = "2007-8-7 15:15:46"
EndDay = "2007-8-8 15:15:46"
BeginDay = Mid(BeginDay,1,9)
EndDay = Mid(EndDay,1,9)

rs.open "select * from [card] where (chongtime between DateValue('" & BeginDay & "') and DateValue('" & EndDay & "')) and ok=1 order by chongtime desc",conn,1,1

首先 字符串应该加单引号

rs.open "select * from [card] where (chongtime between '2007-08-07' and '2007-08-08') and ok=1 order by chongtime desc",conn,1,1

ACCESS查询时间为

记录集=外部数据库。查询("select * from book wher 查询时间 between #"+时间格式(起始时间。今天)+"# and #"+时间格式(终止时间。今天)+"#")

说明:把单引号改为#即可。

string BeginDay = "2006-4-1";
string EndDay = "2006-04-13";
string strcomm = "select * from City where OperatorDay between '" + Convert.ToDateTime(Begi