Ver Mensaje Individual
  #12 (permalink)  
Antiguo 20/10/2012, 10:34
serviopantoja
 
Fecha de Ingreso: agosto-2012
Mensajes: 16
Antigüedad: 11 años, 8 meses
Puntos: 1
Respuesta: resta de fechas para saber edad en mysql

Colega este codigo te puede servir

ami me sirvio 100% comprobado
Código PHP:
CREATE TABLE PAGOS (
  
PAG_CODIGO bigint primary key AUTO_INCREMENT,
  
PAG_CLIENTE bigint not null,
  
PAG_PLAN bigint not null,
  
PAG_PROMOCION bigint,
  
PAG_COSTO bigint,
  
PAG_FECHA_INICIAL date not null,
  
PAG_FECHA_FINAL date not null,
  
PAG_SESIONES_RESTANTES INTEGER,
  
PAG_CADUCADO BOOLEAN DEFAULT 0,
  
PAG_VER BOOLEAN DEFAULT 1  
ENGINE=InnoDB;


INSERT INTO PAGOS VALUES
(1,2,3,4,5,'2012-10-20','2012-10-27',0,0,1),
(
2,2,3,4,5,'2012-10-20','2012-10-29',0,0,1);

UPDATE PAGOS SET PAG_SESIONES_RESTANTES=(SELECT DATEDIFF(PAG_FECHA_FINAL,NOW()));