I have a table with a field of Char(10) Data type
this field contains records of work time Attendance in a decimal format
Ex. I attend today for 8.30 this means eighthours and thirty mintutes
the main problem faced me to make some calculations on those records (sum, subtract, etc)
so I want to convert the data from char type to decimal or real using the next code but it doesn't work
select (cast (satreg, decimal) + cast (satot, decimal)) from timecard
can u please help me in the main issue how to sum char type records or at least how to convert them to decimal
Regards
create table test
(
time char(10)
)
insert into test (time) values ('8.30')
insert into test (time) values ('9.30')
insert into test (time) values ('10.30')
selectconvert(decimal(10,2), time )
fromtest|||
this can help:
it breaks your 8.30 to 8 and 30
SELECT substring(test,0, (patindex('%.%',test))),substring(test,(patindex('%.%',test)+1),len(test)) from test
No comments:
Post a Comment