sql日期问题?
create table tb
(
日期 datetime,
数字 int
)
insert into tb select '2011-08-21 02:10:00.000',10
insert into tb select '2011-08-21 02:20:00.000',20
insert into tb select '2011-08-21 02:30:00.000',30
insert into tb select '2011-08-22 03:10:00.000',100
insert into tb select '2011-08-22 03:20:00.000',200
insert into tb select '2011-08-22 03:30:00.000',300
drop table tb
----------------------------
--我想求2011-8-21这一天的数字这一列的总和
select sum(数字)from tb where 日期='2011-8-21'
但是结果却是null
------解决方案--------------------SQL code
select sum(数字)from tb where 日期 between '2011-8-21 00:00:00' and '2011-8-21 23:59:59'
------解决方案--------------------
select sum(num) from tablename where convert(vcrchar(10),日期,120)='2011-08-21'