关于日期类型的sql语句,谢谢
我想查询日期字段date为"2007-11-26 12:14:55"的记录,在sql server中该如何写查询语句?谢谢
(我用 =、like都不行呀)
[解决办法]
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 行)*/
[解决办法]
--用秒select * from [Table] where datediff(s,'2007-11-26 12:14:55',[Date])=0