Over a million developers have joined DZone.

Get Birthday From Timestamp Field

·
//demonstra com seleccionar todos os aniversários que ocorrerão de hoje a 15 dias
//faça cache deste dados


SELECT SQL_CACHE /*??? prefira memcache, APC, etc..*/
  name,
  birthday,
  YEAR(birthday),
  YEAR(NOW()),
  (YEAR(NOW()) - YEAR(birthday)),
  DATE_ADD(birthday, INTERVAL (YEAR(NOW()) - YEAR(birthday)) YEAR),
  DATE_ADD(NOW(), INTERVAL 15 DAY )

FROM customers

WHERE

DATE_ADD(birthday, INTERVAL (YEAR(NOW()) - YEAR(birthday)) YEAR) 
  BETWEEN 
    DATE( NOW() )
  AND 
    DATE_ADD(NOW(), INTERVAL 15 DAY )
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}