sql时间比较查询当前时间的数据,前一条,后一条

select top 1 * from CheckBill where datediff(second,'2011-05-05 15:56:00',checkDate) > 0 order by CheckDate asc

select top 1 * from CheckBill where datediff(second,checkDate,'2011-05-05 15:56:00') > 0 order by CheckDate desc

select top 1 * from CheckBill where convert(varchar(19),checkDate,120) = '2011-05-05 15:56:00' order by CheckDate desc

select top 3 * from CheckBill order by CheckDate desc


sql时间比较查询当前时间的数据,前一条,后一条_第1张图片

你可能感兴趣的:(sql,ITeye)