开发者

how to convert date 4/7/2011 12:00:00 AM to 7-Apr-2011?

开发者 https://www.devze.com 2023-02-18 11:49 出处:网络
I have a datetime datatype field in mssql2005 database ...开发者_如何学Go which retrieves the date in gridview as .. 4/7/2011 12:00:00 AM

I have a datetime datatype field in mssql2005 database ...开发者_如何学Go

which retrieves the date in gridview as .. 4/7/2011 12:00:00 AM

but i want it retrieve date as 7-Apr-2011

how to do this ?


If this is in a BoundField, try this:

<asp:boundfield datafield="YourDateColumn" dataformatstring="{0:d-MMM-yyyy}" />


You may also go this way;

String.Format("{0:d-MMM-yyyy}", DateTime.Now)

or even;

DateTime.Now.ToString("d-MMM-yyyy");

0

精彩评论

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