select statement today yesterday
Posted: Thu Jul 24, 2008 8:34 am
I want to do a mysql select statement like this
SELECT * FROM x10 WHERE time >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY);
I get
+-------+---------------------+--------------------+--------+
| dtKey | time | apparaat | status |
+-------+---------------------+--------------------+--------+
| 43 | 2008-07-22 21:45:05 | vloerlamp | aan |
| 44 | 2008-07-22 21:49:57 | vloerlamp | aan |
| 45 | 2008-07-22 21:49:58 | vloerlamp | aan |
| 46 | 2008-07-22 22:03:52 | buitenverlichting | aan |
| 47 | 2008-07-22 23:11:36 | buitenverlichting | uit |
| 48 | 2008-07-22 23:11:38 | vloerlamp | uit |
| 49 | 2008-07-23 21:39:53 | vloerlamp | aan |
| 50 | 2008-07-23 21:39:57 | vloerlamp | uit |
| 51 | 2008-07-23 21:42:01 | sproei-installatie | aan |
| 52 | 2008-07-23 21:42:11 | sproei-installatie | uit |
| 53 | 2008-07-23 21:44:14 | vloerlamp | aan |
but I wnat to have it like that if it is today and yesterday he put today and yesterday and not the date. Is this possible with mysql or should I do it with php?
SELECT * FROM x10 WHERE time >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY);
I get
+-------+---------------------+--------------------+--------+
| dtKey | time | apparaat | status |
+-------+---------------------+--------------------+--------+
| 43 | 2008-07-22 21:45:05 | vloerlamp | aan |
| 44 | 2008-07-22 21:49:57 | vloerlamp | aan |
| 45 | 2008-07-22 21:49:58 | vloerlamp | aan |
| 46 | 2008-07-22 22:03:52 | buitenverlichting | aan |
| 47 | 2008-07-22 23:11:36 | buitenverlichting | uit |
| 48 | 2008-07-22 23:11:38 | vloerlamp | uit |
| 49 | 2008-07-23 21:39:53 | vloerlamp | aan |
| 50 | 2008-07-23 21:39:57 | vloerlamp | uit |
| 51 | 2008-07-23 21:42:01 | sproei-installatie | aan |
| 52 | 2008-07-23 21:42:11 | sproei-installatie | uit |
| 53 | 2008-07-23 21:44:14 | vloerlamp | aan |
but I wnat to have it like that if it is today and yesterday he put today and yesterday and not the date. Is this possible with mysql or should I do it with php?