select * from tb where 日期 >='2006-4-28' and 日期<'2006-4-29'
select * from tablename where datediff(日期字段,'2006-04-28')=0
select * from tb where 日期 between '2006-4-28 00:00:00' and '2006-4-28 23:59:59' 呵呵~~~
select * from tablename where 日期=‘2006-04-28’ 这样不是也可以吗??
SELECT * FROM TABLE WHERE CONVERT(NVARCHAR(10),字段,120)='2006-04-29'
jingkekao(可靠)select * from tablename where 日期=‘2006-04-28’ 这样不是也可以吗??------------------------------------------------这样是不行的,这个语句等价于: select * from tablename where 日期=‘2006-04-28 00:00:00.000’只能查出零点零分零秒的数据。
select * from tb where 日期 >='2006-4-28' and 日期<'2006-4-29' 这个最好select * from tablename where datediff(日期字段,'2006-04-28')=0 如果日期上有索引则不能利用SELECT * FROM TABLE WHERE CONVERT(NVARCHAR(10),字段,120)='2006-04-29' 这个同上select * from tb where 日期 between '2006-4-28 00:00:00' and '2006-4-28 23:59:59' 这个就很有问题了,万一有个记录的时间刚好是2006-4-28 23:59:59:500呢?那就查不出来了
select * from tb
where 日期 >='2006-4-28' and 日期<'2006-4-29'
where datediff(日期字段,'2006-04-28')=0
where 日期 between '2006-4-28 00:00:00' and '2006-4-28 23:59:59'
呵呵~~~
where 日期=‘2006-04-28’
这样不是也可以吗??
where 日期=‘2006-04-28’
这样不是也可以吗??------------------------------------------------这样是不行的,这个语句等价于:
select * from tablename
where 日期=‘2006-04-28 00:00:00.000’只能查出零点零分零秒的数据。
where 日期 >='2006-4-28' and 日期<'2006-4-29'
这个最好select * from tablename
where datediff(日期字段,'2006-04-28')=0
如果日期上有索引则不能利用SELECT * FROM TABLE WHERE CONVERT(NVARCHAR(10),字段,120)='2006-04-29'
这个同上select * from tb
where 日期 between '2006-4-28 00:00:00' and '2006-4-28 23:59:59'
这个就很有问题了,万一有个记录的时间刚好是2006-4-28 23:59:59:500呢?那就查不出来了