sql server计算两个时间点的时间差

计算两个时间点的时间差
select datediff(second,’2009-01-05 12:30:00′,’2009-01-10 12:59:00′)
SELECT  CAST(CAST(datediff(second,’2009-01-05 12:30:00′,’2009-01-10 22:59:00′) / (60*60*24) AS INT) AS VARCHAR) + ‘天’
        + CAST(CAST(datediff(second,’2009-01-05 12:30:00′,’2009-01-10 22:59:00′) % 86400 / 3600 AS INT) AS VARCHAR) + ‘小时’
        + CAST(CAST(datediff(second,’2009-01-05 12:30:00′,’2009-01-10 22:59:00′) % 3600 / 60 AS INT) AS VARCHAR) + ‘分’
        + CAST(CAST(datediff(second,’2009-01-05 12:30:00′,’2009-01-10 22:59:00′) % 60 AS INT) AS VARCHAR) + ‘秒’ AS 时间差;

    原文作者:都叫我华哥哥
    原文地址: https://blog.csdn.net/u012521830/article/details/108469928
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞