Created
January 16, 2014 10:01
-
-
Save jgdoncel/48c728bad06e873a228d to your computer and use it in GitHub Desktop.
Filtrar en base a fechas utilizando intervalos desde la fecha actual.
Calcular una diferencia entre fechas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calcular la diferencia entre dos fechas | |
SELECT | |
timestampdiff( | |
HOUR, | |
fecha_1, | |
fecha_2 | |
) AS `tiempo_transcurrido` | |
FROM tabla |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment