I want to be able to calculate the difference between two dates, written in SQL db. The difference must be in days/hours format. This is my code:
Dim SQLConn As New SqlConnection() Dim SQLCmd As New SqlCommand() Dim dr As SqlDataReader Dim arrival As Date Dim departure As Date SQLConn.ConnectionString = ConnString SQLConn.Open() SQLCmd.Connection = SQLConn SQLCmd.CommandText = sqlstr dr = SQLCmd.ExecuteReader While dr.Read() arrival= dr.Item("ODHOD") departure = dr.Item("PRIHOD") End While SQLConn.Close()
I've read timespan is one of the options to use for this case but don't know exactly how to do it..?
Any help would be appreciated.