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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:24:38+00:00 2026-05-27T21:24:38+00:00

I would like to get number of rows that have same date. But one

  • 0

I would like to get number of rows that have same date. But one second must be negligible.

For example ; 2012-01-03 13:12:28 and 2012-01-03 13:12:27 should be perceived as the same.

( I have a table name is myTable and the datetime column name is date )

I hope you will help me..

  • 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-27T21:24:38+00:00Added an answer on May 27, 2026 at 9:24 pm

    It’s as simple as:

    SELECT * FROM myTable WHERE date >= '2012-01-03 13:12:27' AND date <= '2012-01-03 13:12:28';
    

    If you want to build it up from a variable, you could do this:

    $date = '2012-01-03 13:12:27';
    $timestamp = strtotime($date);
    $mysqli = new mysqli();
    
    // Note: allowing 1 second either side, this is up to you
    $lower = date('Y-m-d H:i:s', $timestamp - 1);
    $upper = date('Y-m-d H:i:s', $timestamp + 1);
    
    $stmt = $mysqli->prepare('SELECT * FROM myTable WHERE date >= ? AND date <= ?');
    $stmt->bind_param('ss', $lower, $upper);
    $stmt->execute();
    

    EDIT: As per your comment below, the following SQL should return what you’re after. Note that if a date contains ‘2012-01-03 13:12:28’ it will be counted for both :27 and :28.

    SELECT
        upper_date,
        COALESCE(lower_count, 0) + upper_count
    FROM
        (SELECT
            date AS upper_date,
            COUNT(1) AS upper_count
        FROM myTable
        GROUP BY date
        ) AS upper
    LEFT JOIN
        (SELECT
            date - INTERVAL 1 SECOND AS lower_date,
            COUNT(1) AS lower_count
        FROM myTable
        GROUP BY date
        ) AS lower
    ON upper.upper_date = lower.lower_date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get the number of rows that satisfies the condition. mysql_query(SELECT
I have a number of links which I would like to get some information
I have a query that returns a bunch of rows. But using the same
I have a query like the following that returns the correct number of rows
I would like to get View instance that is used to display specific Preference
I would like to get started developing games with Flixel, but im on a
I have a large number of stored procedures that basically do the same thing:
I have a LinqDataSource that I use to calculate the number of rows in
I have a table with rows that have a number of clicks for a
I would like to get numbers of comments for each posts using mysql. I

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.