sqlsever数据库中查询与某一时间点最接近的记录

求时间字段与输入时间点的时间差j绝对值,最后取最小时间差

SELECT min(ABS(DATEDIFF(MILLISECOND,'2019-12-18 14:11:00.000' ,s.Time))) AS diff  FROM EnergyConsumptions AS s 

 

posted @ 2020-05-21 15:35  も不秃不秃  阅读(914)  评论(0编辑  收藏  举报