22,209
社区成员
发帖
与我相关
我的任务
分享
IF DATEDIFF(MILLISECOND,GETDATE(),GETDATE())=0
BEGIN
PRINT 'Same time'
END
where convert(varchar,[字段名],120)='2017-04-13 10:32:37'
select * from test
where dd >= '2017/4/13 10:32:37.000' AND dd < '2017/4/13 10:32:38'
-- 是不是还有毫秒?
create table test(dd datetime, name varchar(10))
go
insert into test values
('2017/4/13 10:32:36.000', 'xxx'),
('2017/4/13 10:32:37.123', 'yyy'),
('2017/4/13 10:32:38.100', 'zzz')
go
print '-- 条件 '
select * from test where dd = '2017/4/13 10:32:37'
go
print '-- 所有数据'
select * from test
go
drop table test
go
(3 行受影响)
-- 条件
dd name
----------------------- ----------
(0 行受影响)
-- 所有数据
dd name
----------------------- ----------
2017-04-13 10:32:36.000 xxx
2017-04-13 10:32:37.123 yyy
2017-04-13 10:32:38.100 zzz
(3 行受影响)
-- 方便贴些数据上来吗 ?
create table test(dd datetime, name varchar(10))
go
insert into test values
('2017/4/13 10:32:36', 'xxx'),
('2017/4/13 10:32:37', 'yyy'),
('2017/4/13 10:32:38', 'zzz')
go
select * from test where dd = '2017/4/13 10:32:37'
go
drop table test
go
(3 行受影响)
dd name
----------------------- ----------
2017-04-13 10:32:37.000 yyy
(1 行受影响)
select * from test
where dd between '2017/4/13 10:32:37.000' and '2017/4/13 10:32:37.999'
go