tableC
Id beginTime
1 2011-6-7 16:00:04
2 2011-6-6 15:30:03
3 2011-6-7 15:20:00
要在tableC中得出一个距离 2011-6-7 15:30:00(Time1)最近的时间(是绝对值最近的时间)
比如我想得到的时间应该是
Id beginTime
3 2011-6-7 15:20:00
------解决方案--------------------
select top 1 beginTime from tb order by abs(datediff(ss,beginTime,'2011-6-7 15:30:00'))