Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your first step will be to get the timevalues stored in your database into .NET <code>DateTime</code> structs.</p> <p>If you stored them as SQL-DateTime values in the database you can get them directly as <code>DateTime</code>. It would look something like this:</p> <pre><code>SQLCommand getTimeCommand = new SQLCommand("SELECT time FROM table", dbConnection); SQLDataReader myReader = getTimeCommand.ExecuteReader(); while (myReader.Read()) { DateTime time = myReader.GetDateTime(0); } myReader.Close(); </code></pre> <p>Your implementation might differ, refer to the ADO.NET documentation in the MSDN library.</p> <p>If you already got a string representing the time you can parse the string into a <code>DateTime</code> using the static methods </p> <pre><code>DateTime.Parse </code></pre> <p>or </p> <pre><code>DateTime.ParseExact </code></pre> <p>In your case you might need to use <code>ParseExact</code>, which can pe provided with a format-string defining how to read the string. Examples should be found in the MSDN library.</p> <p>Durations in .NET are stored inside a <code>TimeSpan</code> struct. Getting the elapsed time between to datetimes is easy:</p> <pre><code>DateTime time1, time2; //filled with your timevalues from the db TimeSpan elapsed = d2 - d1; </code></pre> <p><code>elapsed</code> now contains the timespan between the two <code>DateTimes</code>. There are several members for the struct to access the <code>TimeSpan</code>. Look into the MSDN-Library to find the ones you need.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload