在SQL中把一个浮点数的整数部分和小数部分分开

select item_no, actual_hours,

(actual_hours/8) as days,

--charindex(‘.‘,cast((actual_hours/8) as varchar))-1 as dianindex,

--cast(left(cast((actual_hours/8) as varchar) , charindex(‘.‘,cast((actual_hours/8) as varchar)) - 1) as int)as zhengshu,

--convert(decimal(18,4),(‘0.‘+reverse(cast(cast(reverse(substring(cast((actual_hours/8) as varchar) , charindex(‘.‘,cast((actual_hours/8) as varchar)) + 1 , len(cast((actual_hours/8) as varchar)))) as int) as varchar))))*8 as hours ,

 --cast(left(cast((actual_hours/8) as varchar) , charindex(‘.‘,cast((actual_hours/8) as varchar)) - 1) as int) as days,

start_date,actual_begin_date

--into #ta 

from work_item 

where actual_complete_date is not null and actual_hours=8 --and charindex(‘.‘,cast((actual_hours/8) as varchar))-1<=-1


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。