表中有一个字段,类型为NVARCHAR
里面有的值为时间,如2008-01-01
现在的问题是,我要作一个时间比较
但是首先要判断这个值是否可以转换为时间
也不知道是否表达清楚了
下面的语句,会出错的,因为有的值不能转换为时间格式
SELECT *
FROM SelectFile
WHERE dscontent='测试' and cast(dscontent as datetime)>getdate()如何比较之前先判断一下呢,感谢大家
里面有的值为时间,如2008-01-01
现在的问题是,我要作一个时间比较
但是首先要判断这个值是否可以转换为时间
也不知道是否表达清楚了
下面的语句,会出错的,因为有的值不能转换为时间格式
SELECT *
FROM SelectFile
WHERE dscontent='测试' and cast(dscontent as datetime)>getdate()如何比较之前先判断一下呢,感谢大家
FROM SelectFile
WHERE ISDATE(dscontent)=1
AND dscontent='测试'
and cast(dscontent as datetime)>getdate()
FROM SelectFile
where ISDATE(dscontent)=1
and dscontent='测试' and cast(dscontent as datetime)>getdate()
SELECT *
FROM SelectFile
where ISDATE(dscontent)=1
and dscontent='测试' and cast(dscontent as datetime)>getdate()
dscontent='测试' and cast(dscontent as datetime)>getdate()这样的条件好像满足不了吧!
SELECT *
FROM SelectFile
where ISDATE(dscontent)=1
and dscontent='测试' and cast(dscontent as datetime)>getdate()
SELECT *
FROM SelectFile
WHERE dscontent='测试' and cast(dscontent as datetime)>getdate() and isdate(dscontent)=1