首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-01-16 
关于日期类型的sql语句,谢谢我想查询日期字段date为2007-11-26 12:14:55的记录,在sql server中该如何写

关于日期类型的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 

热点排行
Bad Request.