当前位置: 代码迷 >> Sql Server >> 关于日期类型的sql语句,多谢
  详细解决方案

关于日期类型的sql语句,多谢

热度:101   发布时间:2016-04-27 19:23:03.0
关于日期类型的sql语句,谢谢
我想查询日期字段date为"2007-11-26 12:14:55"的记录,在sql server中该如何写查询语句?谢谢
(我用 =、like都不行呀)

------解决方案--------------------
SQL code
create table #t(date1 datetime)insert into #tselect getdate() union allselect getdate() union allselect getdate() --查找这条2007-11-13 12:22:33.717select * from #twhere convert(varchar(10),date1,120)='2007-11-13' and convert(varchar(8),date1,114)='12:22:33'/*date1                                                  ------------------------------------------------------ 2007-11-13 12:22:33.717(所影响的行数为 1 行)*/
------解决方案--------------------
SQL code
--用秒select * from [Table] where datediff(s,'2007-11-26 12:14:55',[Date])=0
  相关解决方案