怎么比较日期

btwd 2003-04-09 09:18:18
access数据库,表1 中 有一 "日期" 字段 ,格式为"日期/时间",date1,date2为date型变量。
查询语句 : "select * from 表1 where [日期] between " & date1 & " and " & date2 ,执行结果不对,为什么?
...全文
53 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhangyp 2003-04-09
"select * from 表1 where [日期] between '" & date1 & "' and '" & date2 "'"
回复
younglove 2003-04-09
"select * from 表1 where [日期] between '" & date1 & "' and '" & date2 "'"
这样就可以吧!
我就是这样 弄得
回复
lxcc 2003-04-09
有时候需要加 date1 & "00:00:00"
"select * from 表1 where [日期] between '" & date1 & "00:00:00" & "' and '" & date2 & "23:59:59" &"'"
回复
饮水需思源 2003-04-09
'刚才写反了

SQL数据库为:
"select * from 表1 where [日期] between '" & date1 & "' and '" & date2 &"'"

access数据库为:
"select * from 表1 where [日期] between # " & date1 & " # and # " & date2 & " #"
回复
饮水需思源 2003-04-09
access数据库为:
"select * from 表1 where [日期] between '" & date1 & "' and '" & date2 &"'"

sql数据库为:
"select * from 表1 where [日期] between # " & date1 & " # and # " & date2 & " #"

回复
pcwak 2003-04-09
select * from 表1 where [日期] between '#" & date1 & "#' and '#" & date2 "#'
回复
victorycyz 2003-04-09
"select * from 表1 where [日期] between #" & date1 & "# and #" & date2 "#"
回复
_131_ 2003-04-09
"select * from 表1 where [日期] between '#" & date1 & "#' and '#" & date2 "#'"
回复
cbzdream 2003-04-09
"select * from 表1 where [日期] between '" & date1 & "' and '" & date2 "'"
回复
cbzdream 2003-04-09
"select * from 表1 where [日期] between '" & date1 & "' and '" & date2 "
回复
相关推荐
发帖

1187

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-09 09:18
社区公告
暂无公告