title: QUERY ON DATES TO EXCEL USING C#
body: <p>I was trying to make excel graphs using query in c# and I need to collect data for the last month. I am using the following code and its not giving any error but its not giving any result either.</p>
  
  <p>Basicaly I have the data in excel sheets and using that data im making graphs.</p>
  
  <p>First im geting the two dates and converting them to short string and then im matching the strings with the dates picked from excel in the short strong format.</p>
  
  <p>If anyone could answer, I would really appreciate help.</p>
  
  <p>Thankyou,</p>
  
  <p>THE CODE:</p>
  
  <pre><code>// Get current date and time
  DateTime dtx = DateTime.Now;
  string Date = dtx.ToShortDateString();
  
  // Calculating the last month's date (substracting days from current date.)
  DateTime lastmonth= DateTime.Today.AddDays( -30 );
  string Date2 = lastmonth.ToShortDateString();
  
  OleDbCommand objCmdSelect = new OleDbCommand(
  "SELECT [Hour],(Format(Date, 'Short Date')) AS text_Date,[U_CSSR] FROM [" + excelSheets[j] + "] WHERE CI=" + id + " AND (Format(Date, 'Short Date'))BETWEEN "+ Date + " AND "+ Date2 + " ", objConn);
  </code></pre>