You are here: Re: Format money value as padded string « MsSQL Server « IT news, forums, messages
Re: Format money value as padded string

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация