Leeftijd direct uitrekenen

Iedereen is een keer jarig In plaats van een berekening kan dit in 1x afgehandeld worden
in MySQL. Dit komt overigens van MySQL zelf af. De uitleg staat er ook bij.

SELECT
	id,
	name,
	(
	  YEAR(CURDATE()) - YEAR(dateOfBirth) - (RIGHT(CURDATE(),5) < RIGHT(dateOfBirth,5) )
	) AS age
FROM table
03
Jan 2011
POSTED BY
POSTED IN MySQL
DISCUSSION 0 Comments
TAGS

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>