How to update a sql 2012 database table with the time difference from 2 time frames in vb.net 2010
Posted on 2016-11-03
I have a database that I need to add the difference of 2 times or (wait time). In my database table I have three fields one each for start time, end time, and total wait time. When the table was first created the start and end time got populated but not the wait time. Here is the part of code that I tried to populate the wait time field with.
Dim diff As TimeSpan = CDate(Now.ToShortTimeString).Subtract(CDate(txtInTime.Text))
TextBox9.Text = (diff.TotalMinutes)
TextTotalWaitTime.Text = TextBox9.Text.ToString
txtTotalTime.Text = TextBox9.Text
further in the code is where I update the database with the total wait time.
What I need to be able to do is update all the existing records with the time difference in minutes from Start Time and End Time fields and populate those in the Total Wait Time field in minutes. Going forward I would need to modify my code with the right code to start populating the Total Wait Time field when the program runs.