You are here: Re: Formatting Numeric Value in Computed Column « MsSQL Server « IT news, forums, messages
Re: Formatting Numeric Value in Computed Column

Posted by Stephen C. Smith on 01/14/08 00:00

Thanks everyone who responded. You helped a lot. Those who said to resolve it
in the presentation layer were right. I was writing the front-end in ASP.NET
but couldn't find information on the DataFormatString variable to format it the
way I want. I finally found a site which showed how to do a custom format:

{0:#.000}

.... and that did the trick.

I wasn't able to find any information before on custom formats, which was why I
was trying to do it in SQL Server.

Again, thank you to everyone who stepped forward to help.

Stephen


On Sat, 12 Jan 2008 23:09:11 GMT, nospam@nospam.com (Stephen C. Smith) wrote:

>Hi there --
>
>I'm writing a SQL query that works something like this:
>
>SELECT a, b, a/b AS col_name FROM TABLE
>
>Dividing a by b can result in a value above or below 1, e.g. 1.234 or 0.123.
>
>If the value is below 1, I don't want the preceding zero, e.g. .123.
>
>I've been using a STR() function to format it to three decimal points, e.g.:
>
>STR(a/b, 5, 3) AS col_name
>
>... but for values below 1 it'll look like 0.123.
>
>Any suggestions for how I can make this look like .123?
>
>Thanks in advance.

 

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

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