Ver Mensaje Individual
  #7 (permalink)  
Antiguo 23/02/2006, 14:15
Avatar de claudiovega
claudiovega
 
Fecha de Ingreso: octubre-2003
Ubicación: Puerto Montt
Mensajes: 3.667
Antigüedad: 21 años, 1 mes
Puntos: 11
Hazlo en mysql. Con mysql 5.0.0 tienes esto:

TIMESTAMPDIFF(interval,datetime_expr1,datetime_exp r2)

Returns the integer difference between the date or datetime expressions datetime_expr1 and datetime_expr2. The unit for the result is given by the interval argument. The legal values for interval are the same as those listed in the description of the TIMESTAMPADD() function.

mysql> SELECT TIMESTAMPDIFF(MONTH,'2003-02-01','2003-05-01');
-> 3
mysql> SELECT TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01');
-> -1

TIMESTAMPDIFF() is available as of MySQL 5.0.0.