sql server中的Datetime列到浮点类型转换出现问题
我想将列类型从sql server中的Datetime列到浮点类型转换出现问题,sql,sql-server-2008,sql-server-2005,Sql,Sql Server 2008,Sql Server 2005,我想将列类型从Datetime更改为float。因此,我执行了下面的查询,但它遇到了一个问题 alter table dbo.purchasedate alter column supp_dt float null Error :: Implicit conversion from data type datetime to float is not allowed. Use the CONVERT function to run this query. 在不知道所需输出的情况下,您可以只添
Datetime
更改为float
。因此,我执行了下面的查询,但它遇到了一个问题
alter table dbo.purchasedate
alter column supp_dt float null
Error :: Implicit conversion from data type datetime to float is not allowed. Use the CONVERT function to run this query.
在不知道所需输出的情况下,您可以只添加Float列、填充、删除date列
据我所知,您不能将CONVERT添加到ALTER语句,其他人都知道吗?您想使用什么方案将其转换为float?与显式强制转换相同,其中
0
=1900-01-01
?为什么要这样做呢?我已经从excel中填充了这些数据,其中很少转换为datetime列。所以我想在这个格式上转换这个列实际上包含什么数据?它实际上是数字,但在Excel中格式不正确地设置为datetime列吗?如果是这样,我不认为它将正确往返,除非你手动调整2。e、 g.NOW()
在Excel中是数值的=41430.64
但是选择CAST(41430.64作为日期时间)
返回2013-06-07 15:21:35.997
这是错误的2天。使用显式更新表集F=convert(float,datetime_字段)