title: Date variable assignment from a query
body: <p>I am having some trouble with assigning a variable of type date in a MySQL trigger. When I try to compare my variable to the current date it doesn't work properly.</p>
  
  <pre><code>    CREATE TRIGGER actualizar_numero_sesiones AFTER INSERT ON registroingresos
      FOR EACH ROW
      BEGIN 
      DECLARE d date;
      DECLARE vigente INT(11);
      DECLARE vencido INT(11);
      DECLARE state varchar(10);
      select p.fecha_fin into d from compra_paquete cp, paquetes p where cp.ci = new.ci AND         p.idpaquete = cp.idpaquete;
      SET vencido = d &gt; CURDATE();
      SET vigente = d &lt; CURDATE();
      IF (vencido = 1) THEN
        SET state = 'Vencido';
      IF ELSE(vigente = 1) THEN 
         SET state = 'Vigente';
      END IF;
  END;
  </code></pre>
  
  <p>The query where I assign the variable d is a date value from the "paquetes" table the problem is that the assignment of d variable it's not working properly because I know the dates that are compared fecha_fin ='2012-04-06' and CURDATE() it's after fecha_fin the state value should be "vencido" but it is "vigente"</p>