copy462829 发表于 2008-4-7 16:55

“and”日期问题

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
没有找到一行

shezhenhui1989 发表于 2008-4-7 17:00

你用between试试

copy462829 发表于 2008-4-7 17:08

还是不行·!

buchiputao 发表于 2008-4-8 10:38

回复 1# 的帖子

select a.ddate  ,a.did from m_stockcontent as a  where  a.ddate between  '2008-03-07' and '2018-04-07'

zero_first 发表于 2008-4-9 10:25

不知道你的SQL为什么不提示错误,有两点:第一:你的日期格式没有''号,第二:我不知道你在数据库里的日期格式是不是就2008-01-01的格式还是2008-01-01 00:00:0000,你可以用convert(char(10),变量,120)转换下,试试看

论坛元老 发表于 2008-4-10 15:01

日前格式要用#号啊

lff642 发表于 2008-4-25 17:36

日期型和字符型要使用单引号.

页: [1]

编程论坛