如何转换(在T-SQL中)时间类型40:30:00
(hh:mm:ss),以键入40.30
(十进制)。
答案 0 :(得分:0)
如果您想将时间转换为十进制,请尝试以下查询:
DECLARE @Col DATETIME = '23:30:00'
SELECT cast(datepart(hour, @Col) + datepart(minute, @Col) / 100.00 as
decimal(5, 2))
For Larger value :
DECLARE @Col VARCHAR(100) = '40:30:00'
DECLARE @Col1 BIGINT = CAST(REPLACE(@Col,':','') AS BIGINT)
SELECT CONVERT(DECIMAL(12,2),@Col1)