日期:2014-05-17  浏览次数:20496 次

select日期的问题。
select * from tableGet order by time得到数据如图所示
select * from tableGet where time>='2013年10月28日' and  '2013年10月29日'<time
我想查询10月28号到10月29号之间的数据这么些对吗??

------解决方案--------------------

select * from tableGet 
where time between '2013-10-28' and '2013-10-29'
order by time

------解决方案--------------------
--一般要用convert()函数格式化日期

select * 
from tableGet 
where convert(char(10),[time],120) between '2013-10-28' and '2013-10-29'

------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

Quote: 引用:


改为这样,把后面的< 改为> :
select * from tableGet where time>='2013-10-28' and  '2013-10-29'<time


要仔细


后面的应该是小于号哈,改写一下就是:

select * from tableGet where time>='2013-10-28' and  time > '2013-10-29'




你还是改错了



呵呵,还真是改错了:
select * from tableGet where time>='2013-10-28' and  time <= '2013-10-29'
------解决方案--------------------
引用:
Quote: 引用:
我知道,我问的一开始不清楚,后面说了第三个参数120在这里是什么意思。

http://www.w3school.com.cn/sql/func_convert.asp
------解决方案--------------------
CAST 和 CONVERT (Transact-SQL)

http://msdn.microsoft.com/zh-cn/library/ms187928.aspx