Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 在SQL Server中使用cast或convert将负int值转换为datetime_Sql Server_Sql Server 2005_Casting - Fatal编程技术网

Sql server 在SQL Server中使用cast或convert将负int值转换为datetime

Sql server 在SQL Server中使用cast或convert将负int值转换为datetime,sql-server,sql-server-2005,casting,Sql Server,Sql Server 2005,Casting,我有一些负整数值,它们是默认1-1-1900日期的偏移量。我必须从这些数据中获取日期时间值。我怎样才能做到这一点 例如: 如果我这样做: SELECT convert(datetime, 53691) as Calc OR SELECT cast(53691 as datetime) 我得到:2047-01-01 00:00:00.000 我需要的是,如果我这样做: SELECT convert(datetime, -53691) as Calc OR SELECT cast(-536

我有一些负整数值,它们是默认1-1-1900日期的偏移量。我必须从这些数据中获取日期时间值。我怎样才能做到这一点

例如:

如果我这样做:

SELECT convert(datetime, 53691) as Calc

OR

SELECT cast(53691 as datetime)
我得到:
2047-01-01 00:00:00.000

我需要的是,如果我这样做:

SELECT convert(datetime, -53691) as Calc

OR

SELECT cast(-53691 as datetime)
我应该得到类似于:

1753-01-01 00:00:00.000

-53690将是1753-01-01-53691将您带出范围(不支持1753年之前的日期)。铸造-53690与其他示例一样有效