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 733983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:19:10+00:00 2026-05-14T07:19:10+00:00

I am trying to work out the hits per hour from a database. Data

  • 0

I am trying to work out the hits per hour from a database. Data basically is stored as follows :

Table Name: Visitors
============================
VisitorIP          TIMESTAMP
----------------------------
15.215.65.65       123456789

I want to display total hits per hour (within the last 6 hours ) including the hours that has no hits.
Example of the output:

// Assuming now : 21:00
21:00 - 0 hits
20:00 - 1 hits
19:00 - 4 hits
18:00 - 0 hits
17:00 - 2 hits
16:00 - 3 hits

i would love to get the data as array, Please note that the stored date is in UNIX time stamp format. and there may be some hours without any hits!

Thanks

  • 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-05-14T07:19:11+00:00Added an answer on May 14, 2026 at 7:19 am

    You can use simple keyword BETWEEN for it. You can describe datetime is between values you want to select (range 3600 seconds).

    SELECT * FROM VISITORS WHERE TIMESTAMP BETWEEN UNIX_TIMESTAMP()-3600*1 AND UNIX_TIMESTAMP()-3600*0;
    SELECT * FROM VISITORS WHERE TIMESTAMP BETWEEN UNIX_TIMESTAMP()-3600*2 AND UNIX_TIMESTAMP()-3600*1;
    SELECT * FROM VISITORS WHERE TIMESTAMP BETWEEN UNIX_TIMESTAMP()-3600*3 AND UNIX_TIMESTAMP()-3600*2;
    SELECT * FROM VISITORS WHERE TIMESTAMP BETWEEN UNIX_TIMESTAMP()-3600*4 AND UNIX_TIMESTAMP()-3600*3;
    SELECT * FROM VISITORS WHERE TIMESTAMP BETWEEN UNIX_TIMESTAMP()-3600*5 AND UNIX_TIMESTAMP()-3600*4;
    SELECT * FROM VISITORS WHERE TIMESTAMP BETWEEN UNIX_TIMESTAMP()-3600*6 AND UNIX_TIMESTAMP()-3600*5;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to work out how to parallelize some code from data mining
I am trying work out with MERGE statment to Insert / Update Dimension Table
Im trying to work out how to get the value from one setting in
I am trying to work out how to covert the script below from SQL
I am trying to work out how to do something using regular expressions. Basically,
I trying to work out what regex will match filenames in quotes. Eg. blah
i am trying to work out the following problem in Java (although it could
I am trying to work out why I can not access the nested function
I am trying to work out how I can insert the string End into
I am trying to work out the best practice for my problem. I have

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.