在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


你可能感兴趣的:(convert,actual)