对于时间条件,我总觉得SQL SERVER 设计不完美
比如以下两个条件,就显示不同
select count(0) from 组成员 where ddate = '2009-3-12'
select count(0) from 组成员 where ddate = '2009-03-12'
本来'2009-3-12' 与'2009-03-12' 是相同的啊, 有没有别的写法,让这两个达到统一呢
比如以下两个条件,就显示不同
select count(0) from 组成员 where ddate = '2009-3-12'
select count(0) from 组成员 where ddate = '2009-03-12'
本来'2009-3-12' 与'2009-03-12' 是相同的啊, 有没有别的写法,让这两个达到统一呢
但是你把“时间”转换为字符串或者隐式转换为字符串的话就不行了。
'2009-3-12' 与'2009-03-12'是完全不同的两个字符串。
所以把你的列类型由VARCHAR()类型改为“时间”族类型吧。
select count(1) from 组成员 where isdate(ddate) = 1 and cast(ddate as datetime)= '2009-3-12'
select count(1) from 组成员 where isdate(ddate) = 1 and cast(ddate as datetime)= '2009-03-12'