viernes, 19 de febrero de 2016

substracting time and days from a date


mysql> select now() as currenttime, date_sub(now() , interval 5 day ) as daypassed;
+---------------------+---------------------+
| currenttime         | daypassed           |
+---------------------+---------------------+
| 2016-02-19 20:33:35 | 2016-02-14 20:33:35 |
+---------------------+---------------------+
1 row in set (0.00 sec)






mysql> select now() as currenttime, date_sub(now() , interval 3 hour ) as hourpassed;
+---------------------+---------------------+
| currenttime         | hourpassed          |
+---------------------+---------------------+
| 2016-02-19 20:34:06 | 2016-02-19 17:34:06 |
+---------------------+---------------------+
1 row in set (0.00 sec)

No hay comentarios:

Publicar un comentario