title: mysql - How to concatenate strings and convert to date the strings?
body: <h2>Please take a look at my stored procedure code.</h2>
  
  <pre><code>CREATE DEFINER=`ninjaboy`@`%` PROCEDURE `getMonthlyTotalScore`(IN ninjaId int,  IN month int, IN year int)
  BEGIN
      DECLARE startDate DATE;
      DECLARE endDate DATE;
      DECLARE maxDay INTEGER;
  
      SELECT DAY(LAST_DAY(year + '-' + month + '-01')) INTO maxDay;
  
      SET startDate = year + '-' + month + '-01';
      SET endDate = year + '-' + month + '-' + maxDay;
  
      SELECT SUM(SCORE) FROM NINJA_ACTIVITY WHERE NINJA_ID = ninjaId AND DATE BETWEEN startDate AND endDate ORDER BY DATE;
  END
  </code></pre>
  
  <h2>Test Data:</h2>
  
  <pre>
  NINJA_ACTIVITY_ID | NINJA_ID | SCORE | DATE
  1                   1          24      2012-05-01
  2                   1          36      2012-05-06
  3                   1          29      2012-05-11
  </pre>
  
  <p>Function call : <code>call getTotalMonthlyScore (1, 5, 2012)</code></p>
  
  <p>I'm trying to get the monthly score of any ninja based on the <code>ninjaId</code>.</p>
  
  <p>Why is not working? Any idea where I am getting wrong?</p>