samiam41
asked on
How to update a sql 2012 database table with the time difference from 2 time frames in vb.net 2010
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.ToShortTimeStrin g).Subtrac t(CDate(tx tInTime.Te xt))
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.
Dim diff As TimeSpan = CDate(Now.ToShortTimeStrin
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks this was a huge help. Now my program will do the rest.
ASKER
Icohan, I also liked your solution but not for this process. I would have given you at least 100 points if I could have split the points like that. I know I can find a use for Computed Columns in another SQL project.
Thanks
Thanks
https://msdn.microsoft.com/en-us/library/ms188300.aspx