title: Comparing C# datetime value to SQL Server Compact 4 datetime
body: <p>I'm building an application that stores a group of datetimes to keep track of when I print a particular report.  The report is built up of information from a second table that also has datetimes.  I'm trying to get the report to populate a datagridview with records that are only after the last datetime in the first table.</p>
  
  <p>The first table is called 'deliverylog', this table stores the past print dates.  The second table is called 'joblog', and it stores the records of previous job entries.</p>
  
  <p>When I run the program, it works just fine and populates the gridview with all records after the last date, but it's not refined...  it only populates with dates after the date and not the time.  I need the query to populate the gridview to the second....</p>
  
  <pre><code>DateTime lastDeliveryDate;
  
  private void getLastDelivery() // Sets global variable lastDeliveryDate to the last timestamp entered in the deliverylog table 
  {
      openLogConnection();
  
      try
      {
          command = new SqlCeCommand("SELECT TOP 1 * FROM deliverylog ORDER BY Id DESC", logConn);
  
          drLogSet = command.ExecuteReader();
          while (drLogSet.Read())
          {
              lastDeliveryDate = Convert.ToDateTime(drLogSet["Timestamp"]);
          }
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
      finally
      {
          logConn.Close();
      }
  }
  
  private void populateGridView()
  {
      openLogConnection();
  
      try
      {
          command = new SqlCeCommand("SELECT * FROM joblog WHERE TimeStamp &gt; @date", logConn);
          command.Parameters.AddWithValue("@date", lastDeliveryDate);
  
          dtLogSet = new DataTable();
          bsLogSet = new BindingSource();
          daLogSet = new SqlCeDataAdapter(command);
          cbLogSet = new SqlCeCommandBuilder(daLogSet);
  
          daLogSet.Fill(dtLogSet);
          bsLogSet.DataSource = dtLogSet;
          dataGridView1.DataSource = bsLogSet;
  
          dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
      finally
      {
          logConn.Close();
      }
  }
  </code></pre>
  
  <p>Anyone know how to get the this working right?  I'm storing the timestamps for both tables as datetime data types and in the following format: "MM/dd/yyyy hh:mm:ss tt"</p>