2012-03-13 38 views
0

我遇到MySQL查詢返回表中「最後訪問」字段的問題。MySQL和ASP.NET(vb)問題自動添加到DATE字段

我原本:

select fname, lname, last_visit from patient where isactive = 1 and uid = 1 

的查詢是由我的ASP.NET應用程序中執行這完全在MySQL儘快工作,但是,它在野外的時間也增加了關於日期區域。所以2011-12-12成爲12/12/2011 12:00:00 AM

我想這也沒有改善:

select fname, lname, DATE(last_visit) as last_visit from patient where isactive = 1 and uid = 1 order by lname 

我怎樣才能解決這個問題?

+0

您是否將此日期存儲在DateTime對象中? – 2012-03-13 19:26:01

+0

不,它是MySQL的「日期」 – sor 2012-03-13 19:27:48

+0

我的意思是在VB.net中,它存儲什麼數據類型? – 2012-03-13 19:31:29

回答

2

.NET DateTime對象始終有一個Time組件。在你的應用中,你可以忽略它。

Dim myDate As New DateTime(2011,12,12) 

Dim dateAndTime As String = myDate.ToString() 'Prints 12/12/2011 12:00:00 AM 

Dim onlyDate As String = myDate.ToShortDateString() 'Prints 12/12/2011