We help IT Professionals succeed at work.

formating string to currency and datetime

ziorrinfotech
on
I am reading values from a datatable.
and I want to format the Date to 6/5/2010
and decimal number to $ 100,000.00

how can i do this

This is my code
 If _propertyDetailDataSet.Tables("Property").Rows(0)("DeedRecordingDate") IsNot DBNull.Value And
            CType(_propertyDetailDataSet.Tables("Property").Rows(0)("DeedRecordingDate"), String) <> "1/1/1900" Then

            deedRecordingDateValueLabel.Text = CType(_propertyDetailDataSet.Tables("Property").Rows(0)("DeedRecordingDate"), String)
        End If
        buyInPriceValueLabel.Text = "$" & CType(_propertyDetailDataSet.Tables("PropertyProposed").Rows(0)("BuyInPrice"), String)
Comment
Watch Question

Top Expert 2010
Commented:
for datetime ---> DateTime.ToString("MM/dd/yyyy")

ref: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm


for currency : string str = String.Format("{0:C}", revenue);

ref: http://www.devcurry.com/2009/04/formatting-currency-in-aspnet.html
Shahan AyyubSenior Software Engineer

Commented:
Have a look at this also:

For Date:      
        Dim Inputdate As DateTime = Convert.ToDateTime("6-5-2010")
        Dim FormattedDate As String = Inputdate.ToString("MM/dd/yyyy")

For Amount:
        Dim InputAmt As String = "$ 10000000000"
        Dim Amount As Double = Double.Parse(InputAmt.Replace("$ ", ""))
        Dim deciPart As String = String.Format("{0:#\.##}", Amount)
        Dim IntPart As Integer = String.Format("{0:#\.##}", Amount)
        Dim revenue As String = IntPart.ToString("###,##")
        revenue = "$" + revenue + "." + deciPart.Split(".")(1).ToString()