select statement today yesterday

Pop your questions regarding Home automation software here.....
Post Reply
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

select statement today yesterday

Post by Kroonen »

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?
User avatar
Willem4ever
Global Moderator
Global Moderator
Posts: 805
Joined: Mon Oct 30, 2006 3:48 pm
Location: Uithoorn / Netherlands

select statement today yesterday

Post by Willem4ever »

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by kroon040</i>
<br />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?

<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

You have to do that with php.
Post Reply

Return to “Questions & Discussions Forum”