MySQL Forums
Forum List  »  Spanish

Re: Problema Consulta Fecha Nacimiento
Posted by: Jesús Uzcanga
Date: June 25, 2014 04:45PM

Javier, prueba con este código


SELECT NOMBRE,DATE(fecha_nac) FechaNacimiento,

YEAR(CURDATE())-YEAR(`fecha_nac`)+
IF(DATE_FORMAT(CURDATE(),'%m-%d') > DATE_FORMAT(`fecha_nac`,'%m-%d'), 0, -1) AS `AÑOS`

,MONTH(CURDATE())-MONTH(`fecha_nac`) AS `MESES`

,DAY(CURDATE())-DAY(`fecha_nac`) AS `DIAS`

FROM `personas`

WHERE nombre='pedro';

___________________________
Ing. Jesús Alfredo Uzcanga
Twitter: @JesusUzcanga

We learn the 20% of what we HEAR,
the 50% of what we SEE,
the 80% of what we DO and
the 95% of what we TEACH.

____________________________________________________________
https://www.linkedin.com/in/jauzcanga/

Options: ReplyQuote


Subject
Views
Written By
Posted
1657
June 25, 2014 01:21PM
Re: Problema Consulta Fecha Nacimiento
1147
June 25, 2014 04:45PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.