select * from tablename where datecol between '2004-2-1' and '2005-5-15'
Where 时间字段 Between '2004/2/1' And '2005/5/15'
select * from tmaster1k where tdatetime between '2005-3-1' and '2005-3-23' 時間必須加引號
select * from tbl where datediff(dd,时间字段,'2005-3-1' )<=0 and datediff(dd,时间字段,'2005-3-23')>=0--dd 精确到天 --可换成 yy、mm、ss...
select * from tabelwhere time between cast('2004-2-1 00:00:00' as dateteime) and cast ('2005-5-15 23:59:59' as datetime )
select * from tablename Where 时间字段>convert(char(10), '2004/2/1',126) And 时间字段<convert(char(10), '2005/5/15',126)
select * from tablename where convert(char(10),datecolumn,120) between convert(char(10),convert(datetime,'2004/2/1'),120) and convert(char(10),convert(datetime,'2005/5/15),120) 也就是用convert()函數了。
select * from 表 where 字段 between '2004-2-1 00:00:00' and '2005-5-15 23:59:59'
应该用:select * from 表名 where between '2004-2-1 00:00:00' and '2005-5-15 23:59:59' 就可以啦.
from tablename
where datecol between '2004-2-1' and '2005-5-15'
where tdatetime between '2005-3-1' and '2005-3-23'
時間必須加引號
where datediff(dd,时间字段,'2005-3-1' )<=0
and datediff(dd,时间字段,'2005-3-23')>=0--dd 精确到天
--可换成 yy、mm、ss...
where convert(char(10),datecolumn,120)
between convert(char(10),convert(datetime,'2004/2/1'),120)
and convert(char(10),convert(datetime,'2005/5/15),120)
也就是用convert()函數了。
from 表
where 字段 between '2004-2-1 00:00:00' and '2005-5-15 23:59:59'
where between '2004-2-1 00:00:00' and '2005-5-15 23:59:59'
就可以啦.