Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/01/2011, 16:14
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: Seleccionar cumpleaños del dia MYSQL

Con un ejemplo

Código MySQL:
Ver original
  1. mysql> SELECT *FROM cumple;
  2. +------+------------+
  3. | id   | fecha      |
  4. +------+------------+
  5. |    1 | 2000-08-20 |
  6. |    1 | 1980-08-20 |
  7. |    1 | 1980-08-21 |
  8. |    1 | 1980-01-17 |
  9. |    1 | 1984-01-17 |
  10. |    1 | 2000-01-17 |
  11. +------+------------+
  12. 6 rows in set (0.00 sec)
  13.  
  14. mysql> SELECT c.*,(year(now())-year(fecha)) edad FROM cumple c WHERE DATE_FORMAT(fecha,'%m-%d')=DATE_FORMAT(now(),'%m-%d');
  15. +------+------------+------+
  16. | id   | fecha      | edad |
  17. +------+------------+------+
  18. |    1 | 1980-01-17 |   31 |
  19. |    1 | 1984-01-17 |   27 |
  20. |    1 | 2000-01-17 |   11 |
  21. +------+------------+------+
  22. 3 rows in set (0.00 sec)

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