Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/01/2013, 07:36
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: Insertar default de campo date a fecha posterior

http://dev.mysql.com/doc/refman/5.1/...ate-table.html

Cita:
The DEFAULT clause specifies a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column. See Section 11.3.5, “Automatic Initialization and Updating for TIMESTAMP”.
Parece que no, luego la unica via que te queda es un trigger como te sugieren, on insert.... o simplemente que al construir la sentencia INSERT INTO calcules la fecha y la pongas como un valor...

en codigo simulado...

$dias=SELECT dias FROM vigencia;


INSERT INTO .....(....,vencimiento) VALUES (......., DATE_ADD(NOW(), INTERVAL $dias DAY));
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.

Última edición por quimfv; 23/01/2013 a las 07:46