Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:18:52+00:00 2026-06-11T04:18:52+00:00

I am trying to get registerd users during the last 7 days so I

  • 0

I am trying to get registerd users during the last 7 days so I have the users table

+-----+------------+--------------+
| ID  | USERNAME   | ADDED        |
+-----+------------+--------------+
|  1  | Vlad       | 1347386878   |
+-----+------------+--------------+
|  2  | Test       | 1347386578   |
+-----+------------+--------------+

I tried below sql but the output is empty, no errors… and I need something descending from today to 7 days ago

SELECT date(added), COUNT(id) AS num_registered 
FROM users 
WHERE added < CURDATE() 
AND added > CURDATE() - INTERVAL 7 DAYS 
GROUP BY date(added) LIMIT 1, 7

Any suggestions how to do this?

EDIT:

$mysql_query = mysql_query('SELECT added, DATE(added), COUNT(id) AS num_reg FROM users_test WHERE added < (UNIX_TIMESTAMP() - (7 * 24 * 60 * 60)) GROUP BY DATE(added) LIMIT 1, 7') or die(mysql_error());
while($row = mysql_fetch_array($mysql_query))
{
    $month = date('F', $row['added']);
    $day = date('j', $row['added']);
    $textbuilder .= '
    <li>
        <a href="#" title="'.$month.' '.$day.', '.$row['num_reg'].' registered">
            <span class="label">'.$day.'</span>
            <span class="count" style="height: 20%">('.$row['num_reg'].')</span>
        </a>
    </li>';
}

TABLE:

CREATE TABLE IF NOT EXISTS `users_test` (
  `id` int(10) NOT NULL,
  `username` varchar(60) NOT NULL,
  `added` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `users_test` (`id`, `username`, `added`) VALUES
(1, 'Test', 1347303641),
(2, 'Test1', 1347217241),
(3, 'Test2', 1347130841),
(4, 'Test3', 1347044441);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:18:53+00:00Added an answer on June 11, 2026 at 4:18 am

    ADDED is a UNIX timestamp value, so just do this:

    SELECT
        DATE(Added), Count()
    FROM
        Users
    WHERE
        Added > ( UNIX_TIMESTAMP() - ( 7 * 24 * 60 * 60 ) )
    GROUP BY
        DATE(Added)
    LIMIT
        1, 7
    

    Note that this won’t work in cases where you’re dealing with leap seconds because it uses the approximate definition of a day as 24*60*60, but I imagine you can live with that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get my head around this one: Say you have two models
I have a custom registration form. I am trying to redirect users to a
I'm trying to get a logged in users type (eg super admin, registered). I've
Hello I'm a newbie trying to use django to register some users, I have
I'm trying to figure out some sliding window stats on my users. I have
I have trying to solve an issue with my Spec tests and I get
Like many before me, I'm trying so get my derived types to automatically register
I am trying to use the pt_regs struct to get and set registers such
So i am trying get 2 div-containers which both should contain centered text (Both
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.