title: 'An expression of non-boolean type specified in a context where a condition is expected, near ','.' when date between
body: <p>I am creating a sql query and I want to make profit and loss report
  but I've got this error in my query:</p>
  <blockquote>
  <p>'An expression of non-boolean type specified in a context where a condition is expected, near ','.'</p>
  </blockquote>
  <pre><code>da = new SqlDataAdapter(
  &quot;SELECT
      CAST(Pay_invoice_details.Barcode AS INT), 
      SUM(CAST(Pay_invoice_details.Total_items_price AS INT)) AS 'Total Payes',
      SUM(CAST(Pay_invoice_details.Quantity AS INT) * 
      CAST(Buy_invoice_details.Purchase_price AS INT)) AS 'Total Purchases',
      CAST(Pay_invoice_details.Invoice_date AS DATE), 
      CAST(Buy_invoice_details.Barcode AS INT), 
      CAST(Buy_invoice_details.Invoice_date AS DATE), 
      SUM(CAST(Payouts_details.Total_amount AS INT)) AS 'Total Payouts' 
  FROM 
      Pay_invoice_details,Buy_invoice_details,
      Payouts_details 
  where
      Pay_invoice_details.Barcode = Buy_invoice_details.Barcode and 
      Pay_invoice_details.Invoice_date,
      Buy_invoice_details.Invoice_date,
      Payouts_details.Invoice_date between '&quot; + from.Value.ToString(&quot;yyyy-MM-dd&quot;) + &quot;' and'&quot; + to.Value.ToString(&quot;yyyy-MM-dd&quot;) + &quot;'&quot;,
  sqlcon);
  </code></pre>
  <p>How can I fix this?</p>