This is a discussion on Mysql querry within the MySQL Database forums, part of the Database Forums category; Hi I have a problem with mysql querry SELECT * FROM viewfor_prop_for_search WHERE createdon BETWEEN NOW() AND NOW() + INTERVAL 20 day; ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Sebastian wrote:
> Hi > > I have a problem with mysql querry > > SELECT * FROM viewfor_prop_for_search WHERE createdon BETWEEN NOW() > AND NOW() + > INTERVAL 20 day; > > i try get rows added in last 20 days. > > creadon is datetime type > > Why it doesn't work > > > Sebastian Because now plus 20 days is 20 days from now! E.g. now is Friday. Now plus 2 days is Sunday. Get the idea? |
|
|||
|
== Quote from Sebastian (haja.sebastian@gmail.com)'s article
> > Because now plus 20 days is 20 days from now! > > > > E.g. now is Friday. Now plus 2 days is Sunday. > > > > Get the idea? > Hehe, i make mestake, but with minus is doesn't work to i just tried this on a timestamp field and it didn't work either. -- POST BY: lark with PHP News Reader |
|
|||
|
Sebastian wrote:
>> Because now plus 20 days is 20 days from now! >> >> E.g. now is Friday. Now plus 2 days is Sunday. >> >> Get the idea? > > Hehe, i make mestake, but with minus is doesn't work to Well I don't know why lark couldn't get it to work but I just tried: SELECT * FROM `viewfor_prop_for_search` WHERE `createdon` BETWEEN NOW() - INTERVAL 20 DAY AND NOW(); and it worked fine. Could you post an extract from your table (the create statement and some inserts) and your query so I can see what's wrong. |