【发布时间】:2013-07-22 13:00:03
【问题描述】:
一直在为此苦苦挣扎,似乎找不到正确的答案,尽管有很多关于转换的提及,但没有任何具体的工作。
我需要将数据类型为浮点数的时间转换为小时和分钟。所以 13.50 为 13.30。数据类型与 DB 中的浮点数一样固定,因此无法更改。数据库是 SQL Server 2008R2
试过了:
cast(cast(floor(fdsViewTimesheet.perStandardHours) as
float(2))+':'+cast(floor(100*(
fdsViewTimesheet.perStandardHours - floor(fdsViewTimesheet.perStandardHours)))as
float(2)) as time) AS STANDARD_HOURS
但我收到错误消息 "Explicit conversion from data type real to time is not allowed" 已尝试使用 as char 而不是 as float 但查询挂起。
我做错了什么?我只是want to convert a float value into hours and minutes。
如果有人能指出我正确的方向,将不胜感激。
【问题讨论】:
-
你可以检查这个Answer它肯定会工作
标签: sql-server sql-server-2008 tsql time