homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Count records in mysql table for specific month
timestamp and datetime
sunroof




msg:3919356
 1:27 pm on May 24, 2009 (gmt 0)

Hello guys,

I'm trying to count all the records for a specific month in a table which regdate is timestamp instead of datetime.

The table is phpbb table phpbb_users (user_id, regdate,...).

I need to count all users registered in the specific month (i.e. February 2009, January 2006,... etc).

Thank you

 

lukesimswilson




msg:3920977
 3:40 pm on May 27, 2009 (gmt 0)

To display a Count and the month added for the whole table use the query below.

SELECT count(user_id) as Counter, DATE_FORMAT(regdate,"%M %Y") as DateRegistered FROM table_name GROUP BY DateRegistered

To show a count of all the records for April 2009 for instance you can use:

SELECT Count(*) FROM table_name WHERE DATE_FORMAT(regdate,"%M %Y") = "April 2009"

Try that

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved