目前,我所有的結果都返回'0'。如何計算VB.net中兩個日期之間的差異?
我在做什麼錯?
如果有幫助,當前的代碼將從SQL命令查詢中創建一個數據表,然後分別查看每行以獲取每個日期的差異。
當前代碼:
Dim Con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;DataSource=ApplicationData.accdb;Persist Security Info=False;") Con.Open() 'Open the connection Dim strCommand As String = "SELECT fDateAdded, fName FROM Films" Dim SQL As New OleDb.OleDbCommand(strCommand, Con) Dim DataAdapter As New OleDb.OleDbDataAdapter(SQL) Dim DataTable As New DataTable("Films") ' Create a new data table structure DataAdapter.Fill(DataTable) ' Fill the data table structure from the information in the database. For Each row As DataRow In DataTable.Rows MessageBox.Show(DateDiff(DateInterval.Day, row.Item("fDateAdded"), Now)) Next row Con.Close()