Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/12/2010, 07:41
Avatar de huesos52
huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 15 años, 2 meses
Puntos: 360
Respuesta: Dato que disminuya cada día

mira este ejemplo

Código MySQL:
Ver original
  1. mysql> SELECT *FROM usuarios1;
  2. +------+---------+------------+
  3. | id   | nombre  | fecha_exp  |
  4. +------+---------+------------+
  5. |    1 | daniel  | 2010-11-25 |
  6. |    2 | daniela | 2010-11-15 |
  7. |    2 | daniela | 2010-10-02 |
  8. +------+---------+------------+
  9. 3 rows in set (0.00 sec)
  10.  
  11. mysql> select id,nombre,if((45 - datediff(now(),fecha_exp))<=0,0,datediff(now(),fecha_exp)) expire_days from usuarios1;
  12. +------+---------+-------------+
  13. | id   | nombre  | expire_days |
  14. +------+---------+-------------+
  15. |    1 | daniel  |          12 |
  16. |    2 | daniela |          22 |
  17. |    2 | daniela |           0 |
  18. +------+---------+-------------+
  19. 3 rows in set (0.00 sec)

cambia now por cualquier fecha para que veas que la resta la hace bien.


El if es para evitar mostrar numeros negativos.

saludos
__________________
Without data, You are another person with an opinion.
W. Edwads Deming