ASP:日期作为参数传递,变成字符串了,如何再格式化成日期?

WindowsX 2008-03-22 09:08:41
我的本意是这样的:统计某个时间段的数据,采用(其中 InTime 是记录的录入日期,格式:2008-8-13):
select * from tablename where InTime >= STime and InTime <=ETime order by InTime ASC

STime和ETime从上一页面form中取得:
STime=request("STime")
ETime=request("ETime")

但是这样,取得的日期似乎变成字符串了,所以统计页面出错:标准表达式中数据类型不匹配。

我这样描述我的问题,清楚了吗?还需要补充什么呢?
...全文
165 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶随风 2008-03-22
  • 打赏
  • 举报
回复
没注意有人发过。
晕~~~
不好意思~~~

顺便补充个吧。
要是SQL SERVER数据库
把“#”换成“'”就可以了,分别表示两种数据库的时间常量,我就知道这两个数据库。呵呵……
snlixing 2008-03-22
  • 打赏
  • 举报
回复
value=" <%=date()%>"
WindowsX 2008-03-22
  • 打赏
  • 举报
回复
为什么这个日期没有传过来呢???
WindowsX 2008-03-22
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 leafinwind_ljf 的回复:]
是否传过来,你可以接收后,直接输出看看,就知道了。

我发的那个SQL,试过没?
有什么错误么?
[/Quote]

应该没有什么问题,和wangsdong的一样啊。:)
sql="select * from tablename where InTime >= #"&STime&"# and InTime <= #"&ETime&"# order by InTime ASC"
谢谢啊。。。日期的确没有传过来。。。。
叶随风 2008-03-22
  • 打赏
  • 举报
回复
是否传过来,你可以接收后,直接输出看看,就知道了。

我发的那个SQL,试过没?
有什么错误么?
WindowsX 2008-03-22
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 wangsdong 的回复:]
sql="select * from tablename where InTime >= #"&STime&"# and InTime <=#"&&ETime&"# order by InTime ASC "
[/Quote]上面【#"&&ETime&"#】是不是多了一个【&】了?
使用cdate(request("STime"))之后,变成这样:0:00:00
我怀疑是不是日期没有传过来啊?前一个页面(其中Pcalendar函数选择日期用):
<table width="98%" border="0" cellspacing="1" cellpadding="0" align="center">
<form name="form1" id="form1" method="post" action="Stat.asp?action=search">
<tr>
<td height="25">
生产日期(开始):<input name="STime" type="text" value="<%=date-7%>" size="12" readonly />
<input name="button" type="button" title="选择时间" onClick="Pcalendar(this, form1.STime, 'yyyy-mm-dd')" value="选择" />
生产日期(结束):<input name="ETime" type="text" value="<%=date%>" size="12" readonly />
<input name="button" type="button" title="选择时间" onClick="Pcalendar(this, form1.ETime, 'yyyy-mm-dd')" value="选择" />
<input type="submit" name="Submit" value="统计报表" />
<input type="reset" name="Submit2" value="重置" />
</td>
</tr>
</form>
</table>
叶随风 2008-03-22
  • 打赏
  • 举报
回复
sql="select * from tablename where InTime >= #"&STime&"# and InTime <= #"&ETime&"# order by InTime ASC"

针对ACCESS数据库的,你可以试下
snlixing 2008-03-22
  • 打赏
  • 举报
回复
select * from tablename WHERE (InTime BETWEEN #"&STime&"# AND #"&ETime&"# )
php_wsd 2008-03-22
  • 打赏
  • 举报
回复
sql="select * from tablename where InTime >= #"&STime&"# and InTime <=#"&&ETime&"# order by InTime ASC "
haver.G 2008-03-22
  • 打赏
  • 举报
回复
datediff
WindowsX 2008-03-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 snlixing 的回复:]
select * from tablename WHERE (InTime BETWEEN STime AND ETime )
[/Quote]
不是说,asp中没有between语句的吗?并且我的数据库是ACCESS了。
WindowsX 2008-03-22
  • 打赏
  • 举报
回复
谢谢wangsdong的关注。可是还是出错:
语法错误 (操作符丢失) 在查询表达式 'InTime >=0:00:00 and InTime <= 0:00:00' 中。
难道我的语句写错?看看这样写对不对:
<%
if action="search" then
STime=cdate(request.Form("STime"))
ETime=cdate(request.Form("ETime"))
end if
select * from tablename where InTime >= &STime& and InTime <=&ETime& order by InTime ASC
%>
snlixing 2008-03-22
  • 打赏
  • 举报
回复
select * from tablename WHERE (InTime BETWEEN STime AND ETime )
php_wsd 2008-03-22
  • 打赏
  • 举报
回复
cdate()将字符串转换成日期
WindowsX 2008-03-22
  • 打赏
  • 举报
回复
已经散分啦。只是不明白,其他数据都可以传递,怎么日期没有呢。同在一个form内。type同是text。

<table width="98%" border="0" cellspacing="1" cellpadding="0" align="center">
<form name="form1" id="form1" method="post" action="Stat.asp?action=search">
<tr>
<td height="25">
生产日期(开始): <input name="STime" type="text" value=" <%=date-7%>" size="12" readonly />
<input name="button" type="button" title="选择时间" onClick="Pcalendar(this, form1.STime, 'yyyy-mm-dd')" value="选择" />
生产日期(结束): <input name="ETime" type="text" value=" <%=date%>" size="12" readonly />
<input name="button" type="button" title="选择时间" onClick="Pcalendar(this, form1.ETime, 'yyyy-mm-dd')" value="选择" />
<input type="submit" name="Submit" value="统计报表" />
<input type="reset" name="Submit2" value="重置" />
</td>
</tr>
</form>
</table>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧