|
Posted by Utahduck on 02/22/07 20:11
On Feb 22, 11:33 am, Roy Harvey <roy_har...@snet.net> wrote:
> declare @m money
> set @m = $1.25
>
> select @m, RIGHT(REPLICATE('0',8) +
> convert(varchar(8),convert(int,@m*100)),8)
>
> Roy Harvey
> Beacon Falls, CT
>
> On 22 Feb 2007 10:15:08 -0800, paulmac...@gmail.com wrote:
>
> >Ok my last formatting question.
>
> >How can I insert a money value as a padded string in another table?
>
> >example $1.25 gets inserted to another table as 00000125
>
> >I want 8 total characters and no decimal
>
> >another example would be 4,225.99 becomes 00422599
>
> >can this be done?
>
> >thank you!!
I had a similar project. I did this and it works great:
REPLACE(REPLACE(CONVERT(char(8), @m), '.', ''), ' ', '0')
-Utah
[Back to original message]
|