Formatting data on Select question 
Author Message
 Formatting data on Select question
Hi!

We use Decimal(15,3) to keep currency ammounts in our DB.
With VB I didn't have problems formattiong data for display.
Now I work with ASP and realize that it is simpler to convert number to
string in select statement.

Couldn't figure out on how to do it.

I need 2 decimal chars.

Anyoune know how to do it?

Thanks!



Sun, 26 Dec 2004 04:31:48 GMT
 Formatting data on Select question

select str(X,15,2)

Steve Kass
Drew University

Quote:

> Hi!

> We use Decimal(15,3) to keep currency ammounts in our DB.
> With VB I didn't have problems formattiong data for display.
> Now I work with ASP and realize that it is simpler to convert number to
> string in select statement.

> Couldn't figure out on how to do it.

> I need 2 decimal chars.

> Anyoune know how to do it?

> Thanks!



Sun, 26 Dec 2004 04:39:17 GMT
 Formatting data on Select question
What about:

Mikhail Berlyant
Data Integrator, Data Systems
Launch Your Yahoo!Music Experience  http://launch.yahoo.com
Brainbench MVP for Visual Basic   www.brainbench.com


Quote:
> Hi!

> We use Decimal(15,3) to keep currency ammounts in our DB.
> With VB I didn't have problems formattiong data for display.
> Now I work with ASP and realize that it is simpler to convert number to
> string in select statement.

> Couldn't figure out on how to do it.

> I need 2 decimal chars.

> Anyoune know how to do it?

> Thanks!



Sun, 26 Dec 2004 04:38:10 GMT
 Formatting data on Select question
Misha,

It steel return Numeric value and I need string representation.

0->0.00
0.1->0.10
0.011->0.01


Quote:
> What about:

> Mikhail Berlyant
> Data Integrator, Data Systems
> Launch Your Yahoo!Music Experience  http://launch.yahoo.com
> Brainbench MVP for Visual Basic   www.brainbench.com



> > Hi!

> > We use Decimal(15,3) to keep currency ammounts in our DB.
> > With VB I didn't have problems formattiong data for display.
> > Now I work with ASP and realize that it is simpler to convert number to
> > string in select statement.

> > Couldn't figure out on how to do it.

> > I need 2 decimal chars.

> > Anyoune know how to do it?

> > Thanks!



Sun, 26 Dec 2004 05:13:07 GMT
 Formatting data on Select question
Thanks,

It works.
Does it round number or just cut off digits?


Quote:
> select str(X,15,2)

> Steve Kass
> Drew University


> > Hi!

> > We use Decimal(15,3) to keep currency ammounts in our DB.
> > With VB I didn't have problems formattiong data for display.
> > Now I work with ASP and realize that it is simpler to convert number to
> > string in select statement.

> > Couldn't figure out on how to do it.

> > I need 2 decimal chars.

> > Anyoune know how to do it?

> > Thanks!



Sun, 26 Dec 2004 05:14:44 GMT
 Formatting data on Select question
Vanja, :o)
I thought it is what you expected to see.
Anyway, Steve's answer more appropriate.

Mikhail Berlyant
Data Integrator, Data Systems
Launch Your Yahoo!Music Experience  http://launch.yahoo.com
Brainbench MVP for Visual Basic   www.brainbench.com


Quote:
> Misha,

> It steel return Numeric value and I need string representation.

> 0->0.00
> 0.1->0.10
> 0.011->0.01



> > What about:

> > Mikhail Berlyant
> > Data Integrator, Data Systems
> > Launch Your Yahoo!Music Experience  http://launch.yahoo.com
> > Brainbench MVP for Visual Basic   www.brainbench.com



> > > Hi!

> > > We use Decimal(15,3) to keep currency ammounts in our DB.
> > > With VB I didn't have problems formattiong data for display.
> > > Now I work with ASP and realize that it is simpler to convert number
to
> > > string in select statement.

> > > Couldn't figure out on how to do it.

> > > I need 2 decimal chars.

> > > Anyoune know how to do it?

> > > Thanks!



Sun, 26 Dec 2004 05:24:23 GMT
 Formatting data on Select question
Actually, it converts the number to a float, then rounds.  If you need
absolute precision, you are better off using cast(X as decimal(15,2)),
since sometimes the conversion to float will cause ...5 to round down
instead of up.

Steve

Quote:

> Thanks,

> It works.
> Does it round number or just cut off digits?



> > select str(X,15,2)

> > Steve Kass
> > Drew University


> > > Hi!

> > > We use Decimal(15,3) to keep currency ammounts in our DB.
> > > With VB I didn't have problems formattiong data for display.
> > > Now I work with ASP and realize that it is simpler to convert number to
> > > string in select statement.

> > > Couldn't figure out on how to do it.

> > > I need 2 decimal chars.

> > > Anyoune know how to do it?

> > > Thanks!



Sun, 26 Dec 2004 06:11:18 GMT
 Formatting data on Select question

Quote:
> since sometimes the conversion to float will cause ...5 to round down

are you talking about "bankers" rounding?
If so, then I'm fine.


Sun, 26 Dec 2004 21:38:56 GMT
 Formatting data on Select question
No, it's not banker's rounding.  The reason is explained in a knowledge
base article:

http://mvp.support.microsoft.com/default.aspx?scid=kb;en-us;Q154000

Steve

Quote:

> > since sometimes the conversion to float will cause ...5 to round down

> are you talking about "bankers" rounding?
> If so, then I'm fine.



Sun, 26 Dec 2004 21:44:04 GMT
 Formatting data on Select question
Steve,

Is there any way to tell how it will be rounded? (just out of curiosity)

What happens if I CAST Dec(15,3) as Dec(15,2) ? Does it round it or just
omit 3rd digit?

Thank you!


Quote:
> No, it's not banker's rounding.  The reason is explained in a knowledge
> base article:

> http://mvp.support.microsoft.com/default.aspx?scid=kb;en-us;Q154000

> Steve


> > > since sometimes the conversion to float will cause ...5 to round down

> > are you talking about "bankers" rounding?
> > If so, then I'm fine.



Sun, 26 Dec 2004 22:14:41 GMT
 
 [ 10 post ] 

 Relevant Pages 

1. SQL Select formatting question (outer join?)

2. Select statement format question (T-92)

3. How to format data in SELECT

4. Formatting of DATETIME data type in SELECT statement

5. Easy data types question - free format text

6. Newbie question about formatting the money data type.

7. Newbie question: how to output data in other formats

8. Refreshing Data - Format Question

9. Data in Excel format TYPE XLS Question

10. Basic Data Formatting Question

11. Formatting data in pick format for printing

12. VB4 QUESTION: Updating data fields when selecting from DBCombo


 
Powered by phpBB® Forum Software