Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bug in date count? Or is it me.

Status
Not open for further replies.

salewit

Programmer
Oct 31, 2002
58
US
Here's the data:

Code:
edate      name
2007-01-17 Widget-1
2007-01-25 Widget-2
2007-01-04 Widget-3
2007-02-10 Widget-4
2007-02-01 Widget-5
2007-03-01 Widget-6
2007-03-15 Widget-7
2007-03-20 Widget-8

And I enter this command in PHPMYADMIN:

Code:
SELECT monthname(edate) as mon, year(edate) as yr, count(month(edate)) as cnt FROM widgettable GROUP by mon ORDER by edate;

And this is what I get:

Code:
mon       yr cnt
January  2007 1
February 2007 2
March    2007 3

I'm perplexed. There are clearly 3 "January's" in this table.
 
Arrghhh! Idiot me...

The actual select statement was:

Code:
SELECT monthname(edate) as mon, year(edate) as yr, count(month(edate)) as cnt FROM widgettable WHERE edate > now() GROUP by mon ORDER by edate;

1/4/07 and 1/17/07 is less than now. Never mind!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top