December 24, 2009 at 9:54 am
I need help with converting a decimal field (Hours Worked) to a varchar field.
Required format:
2080.00 hrs. should be displayed as 208000
780.50 hrs. should be displayed as 078050
Other than a case statement that determines the lenght, I'm not sure how to make sure the leading zeroes are included.
Any help would be appreciated.
Thanks,
Jeff
December 24, 2009 at 10:25 am
select
HoursWorked =
right('0000000000'+convert(varchar(10),convert(int,a.HoursWorked*100)),6)
from
( -- Test Data
select HoursWorked = 2080.00 union all
select HoursWorked = 780.50
) a
Results:
HoursWorked
-----------
208000
078050
December 24, 2009 at 10:40 am
I'll give this a try.
Thanks for your quick response.
December 24, 2009 at 10:44 am
That worked great. I didn't think of it that way.
Merry Christmas.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy