title: MySQL - Can't Convert From MSSQL
body: <p>Trying To convert This MSSQL 2012R2 Statement into MySQL 5.7</p>
  
  <pre><code>SELECT SUM(Cost + Credit_Amount) As Daily_Cost FROM Google_Costing
  WHERE Date BETWEEN DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE() -2), 0) AND     
  DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE() -2) + 1, 0)
  </code></pre>
  
  <p>I have tried replacing <code>DATEADD</code> with <code>DATE_ADD</code> and <code>DATEDIFF</code> with <code>TIMESTAMPDIFF</code>, but still no luck. Any help is appreciated.</p>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Incorrect parameter count in the call to native function 'DATEDIFF'</p>
  </blockquote>
  
  <p>So I change the statement to:</p>
  
  <pre><code>SELECT SUM(Cost + Credit_Amount) As Daily_Cost FROM Google_Costing
  WHERE Date BETWEEN DATE_ADD(MONTH, TIMESTAMPDIFF(MONTH, 0, GETDATE() -2), 0) AND 
  DATE_ADD(MONTH, TIMESTAMPDIFF(MONTH, 0, GETDATE() -2) + 1, 0)
  </code></pre>
  
  <p>This time I get the error:</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to
    your MySQL server version for the right syntax to use
    near 'TIMESTAMPDIFF(MONTH, 0, GETDATE() -2), 0) AND DATE_ADD(MONTH,
    TIMESTAMPDIFF(MONT' at line 2</p>
  </blockquote>