p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

sql_language thread: Number Format


Message #1 by "Jed Albao" <jalbao@a...> on Mon, 11 Mar 2002 14:02:33 -0800
Use Float data type:

Formula 			   Output

convert(float, .0250)      0.025
convert(float,100.0250)  100.025
convert(float,100.0000)  100
   
	Eva

-----Original Message-----
From: Jed Albao [mailto:jalbao@a...]
Sent: Thursday, March 14, 2002 1:32 PM
To: sql language
Subject: [sql_language] Re: Number Format


no i haven't looked at CONVERT - i'll look into it.

but for the list record, here's what's goin on:

i'm running sql server 2k.
i have a field that is 'decimal' data type. the precision is 24 and the
scale is 4.

when i output values from this field, the format will always contain 4
decimal places - even if the decimal value is zero (ex. the value 4 will
output as 4.0000 or 4.01 will output 4.0100). also, if the value is less
than zero, the output will not place a zero in the one's place (ex. the
value 0.05 will output as .0500).

referring to the examples above, i would like the value of 4 to output as
simply 4 - not 4.0000; and the value 4.01, i would like to output as 4.01 -
not 4.0100.

actually, to wrap it up in a nut shell, what i REALLY want, is the output to
be exaclty the way it is in the database.

i hope i made myself clear - i've always been lame at explaining myself

tia

-----Original Message-----
From: Jay Turner [mailto:jayt@c...]
Sent: Tuesday, March 12, 2002 7:49 AM
To: sql language
Subject: [sql_language] Re: Number Format


Have you looked at CONVERT? This will add decimals and commas to a
number. Exactly what kind of formatting do you want by the way?

> -----Original Message-----
> From: jalbao@a... [mailto:jalbao@a...]
> Sent: Tuesday, March 12, 2002 7:09 AM
> To: sql language
> Subject: [sql_language] Re: Number Format
>
>
> i'm running sql server 2k
>
> ---- Original Message ----
> From: ken@a...
> To: sql_language@p...,
> Subject: RE: [sql_language] Re: Number Format
> Date: Tue, 12 Mar 2002 16:33:59 +1100
>
> >Let me rephrase my previous post (since it isn't applicable to this
> >list at
> >all...)
> >
> >What DBMS product are you using? Most have inbuilt functions that
> >provide
> >some formatting options.
> >
> >Cheers
> >Ken
> >
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >From: "Jed Albao" <jalbao@a...>
> >Subject: [sql_language] Number Format
> >
> >
> >: is there a function that i can use in a select query that allows
> >us to
> >: format a value on the fly?
> >:
> >: i am looking for something similar to the following:
> >: SELECT numberformatFunction(intField,"number mask")
> >: FROM table
> >
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> >
> >
>
>
> to unsubscribe send a blank email to leave-sql_language-
> 792625D@p...






  Return to Index