查询以选择两个日期之间的数据,格式为m / d / yyyy [英] Query to select data between two dates with the format m/d/yyyy
本文介绍了查询以选择两个日期之间的数据,格式为m / d / yyyy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试从两个日期之间的表中选择记录时遇到问题。
I am facing problem when i'm trying to select records from a table between two dates.
m使用以下查询
select * from xxx where dates between '10/10/2012' and '10/12/2012'
此查询对我有用,但是当日期格式为2013年1月1日时..它不起作用。
this query works for me but when the dates are in format like 1/1/2013.. it doesn't work..
plz尽快解决我的问题。
plz solve my problem ASAP.
推荐答案
此解决方案为谓词中的条件提供CONVERT_IMPLICIT操作
This solution provides CONVERT_IMPLICIT operation for your condition in predicate
SELECT *
FROM xxx
WHERE CAST(dates AS date) BETWEEN '1/1/2013' and '1/2/2013'
OR
SELECT *
FROM xxx
WHERE CONVERT(date, dates, 101) BETWEEN '1/1/2013' and '1/2/2013'
在
这篇关于查询以选择两个日期之间的数据,格式为m / d / yyyy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文