title: How can I convert a colum of DATETIME type to string with linq
body: <p>I have a table with three columns, ID, Date, Expenses, I am trying to search an int in Date column (Type of data in Date column is DateTime). For example, if the year is 1998 and the input is 8, the whole row should be displayed.</p>
  <p>This is my code:</p>
  <pre><code>public ActionResult Get(string searchString)
  {
       DateTime? startDate = new DateTime(2016, 1, 1);
       DateTime? endDate = new DateTime(2018, 12, 5);
  
       AccountingEntities db = new AccountingEntities();
       var expensesValues = from s in db.Expenses
                                   select s;
  
       if (startDate.HasValue)
       {
            expensesValues = expensesValues.Where(s =&gt; s.Date &gt; startDate &amp;&amp; s.Date &lt; endDate);
  
            //This line gives error, I need to convert the s.Date to string so I can use Contains
            expensesValues = expensesValues.Where(s =&gt; s.Date.Contains(searchString));
       }
  }
  </code></pre>