title: Pass Datetime in SQL query in string format?
body: <p>I have string query in and pass @Date object to string. It is giving error. See below code.</p>
  
  <pre><code>Declare @MidDate datetime, @MaxDate datetime
  
  
  set @qrysales_trans_unit_26wks ='update historical_result
      set sales_trans_unit_26wks = (      
              SELECT      
              SUM(sales_trans_unit)
              FROM reg_summary_rowno  WHERE  
              period_idx &gt;= '+  @MidDate  // error 
              +' AND period_idx &lt;'+  @MaxDate /error
              +' AND Client_id ='+ @Client_id
              +' and historical_result.[store_idx] = reg_summary_rowno.[store_idx]
              And [attributes] ='+  @attributes +')'
  </code></pre>
  
  <p>How to pass Datetime object in the proper way to string Query?</p>