title: How can I compare a Date to a DateTime in VB.NET?
body: <p>I just need to compare a date entered by a user to a <code>DateTime</code> stored in my database. I have tried converting the <code>DateTime</code> to <code>Date</code> like this: </p>
  
  <pre><code>select CONVERT(date, startdate) from myTable
  </code></pre>
  
  <p>However, when the information is shown in my <code>GridView</code>, there is still a time attached to the date. (The time shown is 12:00:00.) What can I do to either convert the <code>DateTime</code> to just a <code>Date</code> when the information is pulled from the database, or compare a <code>Date</code> to a <code>DateTime</code>? Why is there still a time shown, even though I converted the <code>DateTime</code> to <code>Date</code>?</p>
  
  <p>**Update</p>
  
  <p>It may be worth noting that I can run the query that populates my <code>GridView</code> in SQL Server Management Studio and the results shown are what I expect-- no time is in the date. I think the problem must be in VB.NET...</p>
  
  <p>**More information</p>
  
  <p>I am having the user fill out a form that will be used to search the database for relevant results. However, as it stands, no results are being returned because the user enters a normal date in the <code>Date</code> field on the form, while the field in the database is a <code>DateTime</code>. This is why I need to know how to convert it.</p>
  
  <p>**Requested Information</p>
  
  <p>Here is the query I'm using:</p>
  
  <pre><code>select convert(date, startdate) as startdate, CONVERT(date, completedate) as completedate
  from myTable
  </code></pre>
  
  <p>Here is the result set in SQL Server Management Studio (no times):</p>
  
  <p><a href="https://i.stack.imgur.com/Mrq3G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mrq3G.png" alt="enter image description here"></a></p>
  
  <p>Here is the result set in the grid (shows times):</p>
  
  <p><a href="https://i.stack.imgur.com/a70Qg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a70Qg.png" alt="enter image description here"></a></p>
  
  <p>I obviously omitted information from the database, but the information shown is all I'm worried about. I had to omit confidential information.</p>