vb.net时间差
您好!数据库表tests,数据:像:toffel 2016-02-27 在listbox1中选中“toffel”,在textbox1中显示“2016-02-27”,在textbox2中显示:还有“61”天
Dim mysql As String = "select tdate from tests where tname ='" & ListBox1.SelectedItem.ToString & "'"
Dim mycmd As New SqlClient.SqlCommand(mysql, myconn)
myconn.Open()
Try
TextBox1.Text = mycmd.ExecuteScalar()
Catch ex As Exception
MsgBox(ex.Message)
End Try
myconn.Close()
Dim dt As Date
dt = CDate(Format(CInt(TextBox1.Text), "0000-00-00"))
Dim b As Date = System.DateTime.Today
Dim c As Long = DateDiff("d", dt, b)
TextBox2.Text = c