zoukankan      html  css  js  c++  java
  • 计算经历的时间

    参考实例:

    --定义变量
    DECLARE @startTime DATETIME
    DECLARE @endTime DATETIME
    DECLARE @HOUR INT
    DECLARE @MINUTE INT
    DECLARE @SECOND INT
    DECLARE @Minutes VARCHAR
    
    --为变量赋值
    SET @startTime = '2020-02-10 08:30:00'
    SET @endTime = '2020-02-19 17:10:09'
     
    SET @HOUR = DATEDIFF(HOUR, @startTime, @endTime)
    SET @MINUTE = DATEDIFF(MINUTE, @startTime, @endTime)
    SET @SECOND = DATEDIFF(SECOND, @startTime, @endTime)
    SET @Minutes = CASE WHEN DATEPART(SECOND, @endTime) >= DATEPART(SECOND, @startTime)
                        THEN CAST((@MINUTE % 60) AS VARCHAR)
                        ELSE
                        CAST((DATEDIFF(MINUTE, DATEADD(MINUTE, -1, @endTime), @endTime) % 60) AS VARCHAR)
                        END
    
    --SELECT
    SELECT  [DD:HH:MM:SS] = CAST((@HOUR / 24) AS VARCHAR) +':'+ CAST((@HOUR % 24) AS VARCHAR) +':'+ @Minutes + ':' + CAST((@SECOND % 60) AS VARCHAR),
            [字符串格式] = CAST((@HOUR / 24) AS VARCHAR) +N''+ CAST((@HOUR % 24) AS VARCHAR) +N'小时 ' + @Minutes + N'分钟 ' + CAST((@SECOND % 60) AS VARCHAR) + N''
    Source Code
  • 相关阅读:
    NSLocalizedString用法
    4-27学习心得
    手势学习
    plist处理
    数据存储
    initWithFrame方法
    控制器跳转小常识
    UIGestureRecognizer学习笔记
    博客资源
    检测手机wifi有没有打开
  • 原文地址:https://www.cnblogs.com/augustuss/p/14022669.html
Copyright © 2011-2022 走看看