如何将Big Int转换为Datetime样式109

时间:2017-10-17 21:46:43

标签: sql sql-server tsql datetime

如何使用以#开头的样式109将Big Int转换为datetime mon dd yyyy hh:mi:ss:mmmAM

632979854880200000是Big INT

select Convert(Datetime,((632979854880200000 - 599266080000000000) / 864000000000),109) AS Datetime from Abc

1 个答案:

答案 0 :(得分:0)

示例

select ViaConvert = Convert(varchar(30),Convert(Datetime,((632979854880200000 - 599266080000000000) / 864000000000.0)),109)
      ,ViaFormat  = Format(Convert(Datetime,((632979854880200000 - 599266080000000000) / 864000000000.0)),'MMM dd yyyy hh:mm:ss tt')

<强>返回

ViaConvert                    ViaFormat
Nov  1 2006  1:44:48:017PM    Nov 01 2006 01:44:48 PM