<p>I wanted to compare the datetime which is in this format "7/20/2008" with the ones in the database which is in format "7/20/2008 7:14:53 AM".</p>

<p>I tried using "like" clause but it did not work beacuse the "like" clause uses only string and the one which I am using is date time format.</p>

<p>Can anyone tell how to convert and compare it in database and pull up datetime.</p>

<pre><code>  protected void User_Querytime()
    {
    DataClasses2DataContext dc1 = new DataClasses2DataContext();
    DateTime date1;


    string date = Request.QueryString.Get("TimeOfMessage");
    date1 = Convert.ToDateTime(date);

    var query7 = from u in dc1.syncback_logs
                 where u.TimeOfMessage = date1
                 orderby u.TimeOfMessage descending
                 select u;
    GridView1.DataSource = query7;
    GridView1.DataBind();
    }
</code></pre>

Although I cannot test your exact problem, I was able to compare dates with the following code.
```
```
// Random Date Collection
    List<DateTime> dateTimes = new List<DateTime>();
    dateTimes.Add(DateTime.Parse("7/20/2008 7:14:53 AM"));
    dateTimes.Add(DateTime.Parse("7/20/2008 7:14:54 AM"));
    dateTimes.Add(DateTime.Parse("7/20/2009 7:14:53 AM"));

    DateTime myDateTime = DateTime.Parse("7/20/2008");

    var query = from d in dateTimes
                where d.ToShortDateString() == myDateTime.ToShortDateString()
                select d;
```
```