【问题标题】:SQL Server 2008 Datetime convert to seconds/milisecondsSQL Server 2008 日期时间转换为秒/毫秒
【发布时间】:2013-10-31 19:17:08
【问题描述】:

--Datetime format = '2013-10-21 12:12:12.000' -- 显然语法很差,但你可以看到我想做什么

select personnum, convert(decimal, shiftEndDate, 4)-convert(decimal, ShiftStartDate, 4) as ShiftInSeconds
from dbo.Time
where shiftStartDate between '2013-10-14 00:00:00.000' and '2013-10-20 23:59:59.000'

【问题讨论】:

    标签: sql-server-2008 datetime converter milliseconds


    【解决方案1】:

    您可以使用DATEFROMPARTSshiftEndDate 创建date 类型,然后将条件字符串转换为日期/日期时间(如果没有,sql 服务器应该自动执行此操作 - 使用CAST/CONVERT

    【讨论】:

      猜你喜欢
      • 2014-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多