create table tb(id varchar(1),riqi datetime)
insert into tb values('A' , '2009-01-22 21:22:22')
insert into tb values('B' , '2009-01-22 19:21:11')
insert into tb values('C' , '2009-01-22 23:10:22')
go
--1
select * from tb where convert(varchar(10),riqi,120) = '2009-01-22'
/*
id riqi
---- ------------------------------------------------------
A 2009-01-22 21:22:22.000
B 2009-01-22 19:21:11.000
C 2009-01-22 23:10:22.000

(所影响的行数为 3 行)
*/

--2
select * from tb where riqi between '2009-01-22 00:00:00' and '2009-01-22 23:59:59'
/*
id riqi
---- ------------------------------------------------------
A 2009-01-22 21:22:22.000
B 2009-01-22 19:21:11.000
C 2009-01-22 23:10:22.000

(所影响的行数为 3 行)
*/

drop table tb

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案