Mysql querry

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; ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-01-2007
Sebastian
 
Posts: n/a
Default Mysql querry

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

Reply With Quote
  #2 (permalink)  
Old 06-01-2007
Paul Lautman
 
Posts: n/a
Default Re: Mysql querry

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?


Reply With Quote
  #3 (permalink)  
Old 06-01-2007
Sebastian
 
Posts: n/a
Default Re: Mysql querry


> 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

Reply With Quote
  #4 (permalink)  
Old 06-01-2007
lark
 
Posts: n/a
Default Re: Mysql querry

== 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
Reply With Quote
  #5 (permalink)  
Old 06-02-2007
Paul Lautman
 
Posts: n/a
Default Re: Mysql querry

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.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:55 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0