开发者

Format date(mm,dd,yyy) that is being pulled from database that is populated into a textbox

I have an Asp web form (language is VB) that is used to update reco开发者_StackOverflow中文版rds in a SQL database. The form is populated with the record with many textboxes as well as dropdownlists. I have a textbox that is populated with a date from the record and is displayed with the date and the time. I would like change the format to only display the date as "mm-dd-yyy". In the code behind the date field is called from the database and put into the textbox via: "MyDate.Text = dt.Rows(0)("MyDate").ToString()". Thanks in advance for any help that is offered.


MyDate.Text = dt.Rows(0)("MyDate").ToString("MM-dd-yy");

See this link for a reference on what else you can do with format strings:

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx


In your SQL select you can format the date in this way:

SELECT CONVERT(nvarchar(30),MyDate,110) as MyDate, ...
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜