Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old January 29th, 2008, 11:02 AM
bigbavarian bigbavarian is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 42 bigbavarian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 29 m 18 sec
Reputation Power: 2
MySQL 4 - Count of records within the past 7 days not correct

Hello all,

I have a query where I would liek to pull the count of all the records added to various tables within the last seven days. For some reason the results are incorrect and I can't seem to figure out why. All the tables listed int he query below have not had any records added since 1/19/2008 (10 days ago) but the query says there is one for the members table and one for the brewery table. Can anyone tell me what I am doing wrong?


$query_weekly_stats = "
SELECT COUNT( * ) AS `stats`
FROM `members`
WHERE WEEK( `CreateDate`, 7 ) = WEEK( NOW(), 7 )
UNION ALL
SELECT COUNT( * ) AS `stats`
FROM `brewerytable`
WHERE WEEK( `BreweryCreateDate`, 7 ) = WEEK( NOW(), 7 )
UNION ALL
SELECT COUNT( * ) AS `stats`
FROM `beerstable`
WHERE WEEK( `BeerCreateDate`, 7 ) = WEEK( NOW(), 7 )
UNION ALL
SELECT COUNT( * ) AS `stats`
FROM `labels`
WHERE WEEK( `create_date`, 7 ) = WEEK( NOW(), 7 )
UNION ALL
SELECT COUNT( * ) AS `stats`
FROM `bottlecaps`
WHERE WEEK( `create_date`, 7 ) = WEEK( NOW(), 7 )
UNION ALL
SELECT COUNT( * ) AS `stats`
FROM `coasters`
WHERE WEEK( `coaster_create_date`, 7 ) = WEEK( NOW(), 7 )
";
$weekly_stats_result = mysql_query($query_weekly_stats);
while ( $stats_data = mysql_fetch_assoc( $weekly_stats_result ) ) {
$weekly_stats .= $stats_data['stats']."<br />";

Reply With Quote
  #2  
Old February 7th, 2008, 08:22 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,719 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 4 m 29 sec
Reputation Power: 6
have you broken out the ones that are returning the incorrect data to see the record and the dates in it that is returning?
__________________
life is a game.... Have fun
-----------------------------
http://www.phpwomen.org
strength in unity

PHPCommunity IRC
#phpc on freenode

Reply With Quote
  #3  
Old February 20th, 2008, 08:04 PM
bigbavarian bigbavarian is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 42 bigbavarian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 29 m 18 sec
Reputation Power: 2
I am having a problem because in my development environment it works perfectly fine. I didn't want to mess with production. I guess I will have to.

Thanks,

Stephen

Reply With Quote
  #4  
Old April 1st, 2008, 09:00 AM
bigbavarian bigbavarian is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 42 bigbavarian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 29 m 18 sec
Reputation Power: 2
I was finally able to see what records are being included that shouldn't be. Today when I went to the site it said that there were 6 new labels and 5 new bottlecaps. When I looked at the database I found that it has something to do with how the date is being read.

The query is pulling items with the following date

2007-04-07 14:21:46
2007-04-07 15:57:21
2007-04-07-15:57:57

Not
2007-12-12 06:21:23
2007-12-27 17:25:12

So it looks like it is pulling items regardless of the year AND up to seven days in the future. I would like to only have items that were added within the LAST seven days.

Any help would be greatly appreciated.

Stephen

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > MySQL 4 - Count of records within the past 7 days not correct


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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