本文介绍了日期条件检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Iam使用sql server 2005作为我的后端
iam使用带有日期条件的查询。
Iam USing sql server 2005 as my back end
iam using query with date condition.
select * from Purchase v
where cast( v.DocDate as datetime) >= cast('Sep 26 2014 12:00AM'as datetime )
and cast( v.DocDate as datetime) < cast('Aug 27 2014 12:00AM' as datetime)
执行上述查询时我无法得到任何结果
但是有记录。
你能告诉我我的错误吗?国王
谢谢
问候
Nirmala Sarvanan
when the above query is executed i cant get any results
but records are there.
Can u tell me what mistake iam making
Thanks
Regards
Nirmala Sarvanan
推荐答案
select * from Purchase v
where cast( v.DocDate as datetime) <= cast('2014-09-26 12:00:00.000'as datetime )
and cast( v.DocDate as datetime) > cast('2014-08-10 12:00:00.000' as datetime)
select * from Purchase v
where convert(varchar,cast( v.DocDate as datetime),100) <= convert(varchar,cast('Sep 26 2014 12:00AM' as datetime),100)
and convert(varchar,cast( v.DocDate as datetime),100) >= convert(varchar,cast('Aug 27 2014 12:00AM' as datetime),100)
这篇关于日期条件检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!