General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 9th, 2003, 07:50 PM
rasputinj rasputinj is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 5 rasputinj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help to query date range from Now to 7 days ago

I am running phpnuke with mysql and I am try to modify a top 15 module that pulls the 15 most read stories. I would like to modify it to only show the most read stories in the last 7 days

Here is the current query


PHP Code:
 select sidtitlecounter from ".$prefix."_stories  order by counter DESC limit 0,$top", $dbi); 


the field Time is setup in this format 2003-09-02 11:40:46

I had tried to add this to the query before order by

PHP Code:
 Where time between now() and now() - interval 7 days 


I do not get an error when I run, I just get no results. Is Time a reserved word? Do I need quotes around it, and can I use interval with now()?

I am a newbie when it comes to Mysql, I am trying to learn though. Any help would be appreciated.

Reply With Quote
  #2  
Old September 10th, 2003, 05:03 AM
Arash-mikaeili Arash-mikaeili is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Iran,Tehran
Posts: 7 Arash-mikaeili User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

Hi Buddy;

about your Problem in query you simply can user this instead that you wrote in your post :


PHP Code:
 select tbldate.* from tbldate where 
fldDate 
<= curdate() and fldDate >= DATE_SUB(curdate(),INTERVAL 7 day


curdate() return curen date and Date_sub() performs date arecmathic subtract.

Last edited by Arash-mikaeili : September 10th, 2003 at 05:08 AM.

Reply With Quote
  #3  
Old September 10th, 2003, 11:10 AM
rasputinj rasputinj is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 5 rasputinj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you very much I will try it out..

Reply With Quote
  #4  
Old September 10th, 2003, 03:48 PM
Arash-mikaeili Arash-mikaeili is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Iran,Tehran
Posts: 7 Arash-mikaeili User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
you are welcome

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Help to query date range from Now to 7 days ago


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT