开发者

format the column (date) in an dataset

开发者 https://www.devze.com 2023-02-03 04:08 出处:网络
i have an datasetwith an column name asDATE it contain开发者_如何学Cs an value in this format 1/5/2010(month/day/year).

i have an dataset with an column name as DATE it contain开发者_如何学Cs 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.


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");


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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消