Skip to content

Instantly share code, notes, and snippets.

@csalgueiro
Created January 20, 2014 08:55
Show Gist options
  • Save csalgueiro/8517003 to your computer and use it in GitHub Desktop.
Save csalgueiro/8517003 to your computer and use it in GitHub Desktop.
Filtrar en base a fechas utilizando intervalos desde la fecha actual.
// Obtener registros de la tabla con fecha superior a hace tres meses
SELECT * FROM tabla WHERE fecha >= DATE_ADD(NOW(),INTERVAL -3 MONTH)
// De otro modo:
SELECT * FROM tabla WHERE fecha >= (NOW() + INTERVAL -3 MONTH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment