SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    California
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Display New Entries Based On Month & Unixstamp

    Hello.

    I have a mysql database with a users table. Within the users table is a datestamp in unix timeformat. (php: date("U"))

    I need to know the SQL statment to acquire all of the new members for each month.

    I am in need of creating a new php page that lists all the users for each month, broken down into a month-by-month basis.

    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,022
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    if the column is called dateadded,
    Code:
    select year(from_unixtime(dateadded))  as theyear
         , month(from_unixtime(dateadded)) as themonth
         , count(*)                        as newusers
      from users     
    group
        by year(from_unixtime(dateadded))  
         , month(from_unixtime(dateadded))
    order 
        by theyear desc
         , themonth desc
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    California
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow, amazing!

    Thanks!!! I'm 100% positive I'd have never figured that out so easily.

    I knew I could do it via php and a bunch of nasty sqls... but I was really hoping someone out here would know how to save me the work!!

    So, thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •