select * from tablename where in_time>'2004-4-6' and in_time<'2004-5-8' and out_time>'2004-4-6' and out_time<'2004-5-8'
解决方案 »
- 如何解决csv导入SQL时数据里带‘,’的问题?
- sql server 2000 数据库关于列的问题
- 选择一个表中一列插入另一个表
- 插入一条记录后,怎么样才能获得刚才插入的记录的序列号或者其他根据记录内容生成的数据?
- Windows 7下安装SQLServer2008出现“ 试图执行未经授权的操作” 是什么意思?
- 如何优化5000条数据 group by 日期 取前6条结果
- 现在本机上已经装了Sql server 2000,再想装一个Sql Server 2005,可是不知道怎么装?
- SQL数据库转空间还原备份后,ID不能自动增长?重新设置了ID属性都没用?为什么?
- 怎样用简单的 SQL 语句打开一个脚本文件(与 SQL Server 在同一机器上)并执行它?
- 提高VFP6.0买那个出版社的,谁编著的比较好
- 请大家给个意见:为2个字段,需要另建一个表吗?
- 请高手帮忙,如何进行具体时间比较
where in_time between '2004-4-6' and '2004-5-8'
and out_time between '2004-4-6' and '2004-5-8'
where in_time>='2004-4-6' and in_time<='2004-5-8'
and out_time>='2004-4-6' and out_time<='2004-5-8'
where in_time>='2004-4-6' and in_time<='2004-5-8'
and out_time>='2004-4-6' and out_time<='2004-5-8'
在sql server是可以直接比较的
conn.Open "mydata","sa",""
y1=Request.Form("year1") 'y1,y2,m1,m2,d1,d2都是从前一页面而来
y2=Request.Form("year2")
m1=Request.Form("month1")
m2=Request.Form("month2")
d1=Request.Form("day1")
d2=Request.Form("day2")
temp1=y1&"-"&m1&"-"&d1
temp2=y2&"-"&m2&"-"&d2
temp1=FormatDateTime(temp1) ‘把temp1,temp2的格式转换成DateTime类型
temp2=FormatDateTime(temp2)
s="select * from worktime where LoginID='"&session("loginid")&"' and Workdate between "&temp1&" and "&temp2
Set rs=conn.Execute(s)
session("loginid")中保存着wang
我想查询2004-4-1到2004-5-1的wang的记录,请问上边的rs执行结果是否正确??
我的执行结果为什么rs是NULL,而表中有wang的记录啊??怎么回事?
还请高手指点一下
WORKTIME表
ID NAME LOGINID WORKTIME WORKDATE LEAVE
1 wang wang 7:58:53 2004-4-10 空
3 wang wang 8:00:00 2004-4-11 事假
7 li li 7:30:14 2004-4-15 病假
12 wang wang 7:45:00 2004-4-16 病假
conn.Open "mydata","sa",""
y1=Request.Form("year1") 'y1,y2,m1,m2,d1,d2都是从前一页面而来
y2=Request.Form("year2")
m1=Request.Form("month1")
m2=Request.Form("month2")
d1=Request.Form("day1")
d2=Request.Form("day2")
temp1=y1&"-"&m1&"-"&d1
temp2=y2&"-"&m2&"-"&d2
temp1=FormatDateTime(temp1) ‘把temp1,temp2的格式转换成DateTime类型
temp2=FormatDateTime(temp2)
s="select * from worktime where LoginID='"&session("loginid")&"' and Workdate between '"&temp1&"' and '"&temp2 & "'"
Set rs=conn.Execute(s)
s="select * from worktime where LoginID='"&session("loginid")&"' and Workdate between "&temp1&" and "&temp2改为:
s="select * from worktime where LoginID='"&session("loginid")&"' and Workdate between '"&temp1&"' and '"&temp2 & "'" --你的少了单引号
谢谢