日期:2014-05-16  浏览次数:20473 次

如何把字符串7:30变为7.5
如何把
字符串7:30变为7.5
字符串7:20变为7.3
。。。。。等等


------解决方案--------------------

create table wy
(x varchar(10),y varchar(10))

insert into wy(x)
 select '7:30' union all
 select '7:20'


update wy
 set y=substring(x,1,charindex(':',x,1)-1)+'.'
      +rtrim(cast(substring(x,charindex(':',x,1)+1,10) as int)/6)


select * from wy

/*
x          y
---------- ----------
7:30       7.5
7:20       7.3

(2 row(s) affected)
*/