注册 登录
编程论坛 SQL Server论坛

“and”日期问题

copy462829 发布于 2008-04-07 16:55, 995 次点击
select a.ddate  ,a.did from m_stockcontent as a  where  a.ddate > 2008-03-07
显示2条记录
2008-08-08 00:00:00.000  1101    
2009-01-01 00:00:00.000  1101

当我加入一个条件
select a.ddate  ,a.did from m_stockcontent as a  where  a.ddate > 2008-03-07 and  a.ddate<2018-04-07
没有找到一行
6 回复
#2
shezhenhui19892008-04-07 17:00
你用between试试
#3
copy4628292008-04-07 17:08
还是不行·!
#4
buchiputao2008-04-08 10:38
回复 1# 的帖子
select a.ddate  ,a.did from m_stockcontent as a  where  a.ddate between  '2008-03-07' and '2018-04-07'
#5
zero_first2008-04-09 10:25
不知道你的SQL为什么不提示错误,有两点:第一:你的日期格式没有''号,第二:我不知道你在数据库里的日期格式是不是就2008-01-01的格式还是2008-01-01 00:00:0000,你可以用convert(char(10),变量,120)转换下,试试看
#6
论坛元老2008-04-10 15:01
日前格式要用#号啊
#7
lff6422008-04-25 17:36
日期型和字符型要使用单引号.
1