happysmile
happysmile

Reputation: 7777

format the column (date) in an dataset

i have an dataset with an column name as DATE it contains an value in this format 1/5/2010(month/day/year).

Now i need to change the data been displayed(format). 05-01-2010

any help how to solve this issue would be great.

Upvotes: 0

Views: 1289

Answers (2)

Afnan Bashir
Afnan Bashir

Reputation: 7429

You can parse it to DateTime and then back to required string. Hope this helps.

 DateTime d=DateTime.Parse("11/01/2005");    
 MessageBox.Show(d.ToString("dd-MM-yyyy"));

Tested :)

Upvotes: 0

Ta01
Ta01

Reputation: 31630

Set the dataformatstring of the bound column to: "{0:dd-MM-yyyy}"

EDIT: for some reason I assumed you were binding to a grid, in any event, that format specifier will work if you do yourDateTimeVariable.ToString("dd-MM-yyyy");

Upvotes: 1

Related Questions