Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

converting SQL money to Double variable chopes of zeros  c#

Posted on 2007-04-06
4
Medium Priority
?
1,046 Views
Last Modified: 2012-06-21
I have a SQL Table Column whos data type is money...
I convert that to a double for working with as a variable...

Problem I am having is that it chops off zero's
WHen I convert the money to Double if the money is 3.5000 t nds up 3.5 but I need it to be 3.50.

Anyone know how I can do this in the conversion
0
Comment
Question by:Prysson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 18869044
3.5000 t nds up 3.5 but I need it to be 3.50.


what does this mean

if ur money is

3.54600 it will show as 3.546 and if its
3.00000 it will show as 3

but how does that make a difference both are double rt

0
 

Author Comment

by:Prysson
ID: 18869821
I need the value to display in a standard dollar format

2.00
3.00
3.50
3.70

not
2
3
3.5
3.7

So in short I want my variable to hold onto two decimal places in the number regardless of whether they are zero's or not. I dont want it it truncating it. I need to know how to do this.



etc etc
0
 

Author Comment

by:Prysson
ID: 18870749
The Solution I was looking for was actual a problem of presenting the data in the presentation layer. Basically I needed to convert the doubel to a string("c"0

double d = 2.5;
string s = d.ToString("c");

s = $2.50
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 1500 total points
ID: 18871584
u could do this then

string str = double.ToString("0,0.00");
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Loops Section Overview

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question