title: How to use timestamp in MySQL stored procedure
body: <p>I am new in stackoverflow.
  Also, please forgive me for my english.</p>
  
  <p>I have a question about using timestamp in MySQL stored proc.
  I am using MySQL 5 and MySQLdb Python module (Python version 2.6).
  Here is a code to create my stored procedure:</p>
  
  <pre><code>def create_procedure_sum_shift ():
      global cursor
  
      cursor.execute("CREATE PROCEDURE `sum_shift`\
      (IN s_Time DATETIME, IN e_Time DATETIME)\
      BEGIN\
      SET @q = concat('SELECT * FROM trig_test WHERE `t_stamp`&gt;=',\
      s_Time,' AND `t_stamp` &lt;= ', e_Time);\
      PREPARE query FROM @q;\
      EXECUTE query;\
      deallocate prepare query;\
      END;")
  </code></pre>
  
  <p>When I am trying to create this proc, everything is ok.
  But, when i am calling this proc, I am getting an error.
  Here is a call of this procedure: </p>
  
  <pre><code>def call_sum_shift(startDate, endDate):
      global cursor
      cursor.execute("call sum_shift(DATE('%s'),DATE('%s'));" % (startDate, endDate))
      rows = cursor.fetchall()
      discr = cursor.description
      return rows,discr
  </code></pre>
  
  <p>startDate (and endDate) I get this:</p>
  
  <pre><code>time = datetime.datetime(2012, 07, 25, 8, 00, 00)
  startDate = str (time)
  </code></pre>
  
  <p>Here is the an error:</p>
  
  <pre><code>..._mysql_exceptions.ProgrammingError:(1064,"You have an error...for the right syntax to    use near '00:00:00 AND `t_stamp` &lt;= 2012-07-25 00:00:00` at line 1)
  </code></pre>
  
  <p>Where is my mistake? If it possible, please give an example, of using  the "timestamp" in MySQL stored proc.</p>
  
  <p>Thanks in advance.</p>