有个表 字段 mytime
a. 2007-09-02 12:12:12.787
b. 2007-09-03 12:12:12.787
c. 2007-09-07 12:12:12.787
d. 2007-09-21 12:23:34.543是datatime类型我现在想取出b,c两条记录 类似 mytime>2007-09-03 and mytime<2007-09-21
正确的怎么写?
a. 2007-09-02 12:12:12.787
b. 2007-09-03 12:12:12.787
c. 2007-09-07 12:12:12.787
d. 2007-09-21 12:23:34.543是datatime类型我现在想取出b,c两条记录 类似 mytime>2007-09-03 and mytime<2007-09-21
正确的怎么写?
a. 2007-09-02 12:12:12.787
b. 2007-09-03 12:12:12.787
c. 2007-09-07 12:12:12.787
d. 2007-09-21 12:23:34.543是datatime类型我现在想取出b,c两条记录 类似 mytime>'2007-09-03' and mytime<'2007-09-22'
正确的怎么写?select * from tb where mytime>'2007-09-03' and mytime<'2007-09-22'
select * from tb where mytime>='2007-09-03 00:00:00.000' and mytime<='2007-09-21 23:59:59.999'
declare @T1 table(id varchar(2),mytime datetime)
insert @T1
select 'a.','2007-09-02 12:12:12.787' union all
select 'b.','2007-09-03 12:12:12.787' union all
select 'c.','2007-09-07 12:12:12.787' union all
select 'd.','2007-09-21 12:23:34.543'select * from @T1 where mytime>='2007-09-03' and mytime<'2007-09-21'
a. 2007-09-02 12:12:12.787
b. 2007-09-03 12:12:12.787
c. 2007-09-07 12:12:12.787
d. 2007-09-21 12:23:34.543是datatime类型我现在想取出b,c两条记录 类似 mytime>2007-09-03 and mytime<2007-09-21
正确的怎么写?select * from table where mytime>='2007-09-03' and mytime=<'2007-09-21'