目前,我所有的结果都返回'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()