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

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 March 29th, 2004, 12:28 PM
m0untaind0g m0untaind0g is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 18 m0untaind0g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 10 sec
Reputation Power: 0
Send a message via AIM to m0untaind0g
date_sub function issues

Hi There,
Perhaps someone could lend me a hand here on this query. I have a query where I would like it to SUM up the last 7 days of records further (one week), it needs to start a new week on Monday. The 'time_upload' field is a datetime field. Currently the results I am getting at all the rows being added.

What am I doing wrong or not doing here ?

$query = "SELECT SUM(distance) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload ";

Thanks,
Craig H.

Reply With Quote
  #2  
Old March 30th, 2004, 06:37 AM
crudesys crudesys is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: California
Posts: 25 crudesys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
$query = "SELECT SUM(distance) FROM TRAININGLOG WHERE time_upload >= DATE_SUB( NOW(),INTERVAL 7 DAY ) ";

your field in the table is 'time_upload'. probably you would need this field to be the reference in the condition, not date_sub(...).
i hope this works. worth a try

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > date_sub function issues


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