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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:20:46+00:00 2026-05-30T09:20:46+00:00

All I want to count entries based on date.(i.e entries with same date.) My

  • 0

All I want to count entries based on date.(i.e entries with same date.)
My table is

enter image description here
You can see 5th and 6th entry have same date.

Now, the real problem as i think is the same date entry have different time so i am not getting what I want.

I am using this sql

SELECT COUNT( created_at ) AS entries, created_at
FROM wp_frm_items
WHERE user_id =1
GROUP BY created_at
LIMIT 0 , 30

What I am getting is this.

enter image description here

I want entries as 2 for date 2012-02-22

  • 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-30T09:20:48+00:00Added an answer on May 30, 2026 at 9:20 am

    The reason you get what you get is because you also compare the time, down to a second apart. So any entries created the same second will be grouped together.

    To achieve what you actually want, you need to apply a date function to the created_at column:

    SELECT COUNT(1) AS entries, DATE(created_at) as date
    FROM wp_frm_items
    WHERE user_id =1
    GROUP BY DATE(created_at)
    LIMIT 0 , 30
    

    This would remove the time part from the column field, and so group together any entries created on the same day. You could take this further by removing the day part to group entries created on the same month of the same year etc.

    To restrict the query to entries created in the current month, you add a WHERE-clause to the query to only select entries that satisfy that condition. Here’s an example:

    SELECT COUNT(1) AS entries, DATE(created_at) as date 
    FROM  wp_frm_items
    WHERE user_id = 1 
      AND created_at >= DATE_FORMAT(CURDATE(),'%Y-%m-01') 
    GROUP BY DATE(created_at)
    

    Note: The COUNT(1)-part of the query simply means Count each row, and you could just as well have written COUNT(*), COUNT(id) or any other field. Historically, the most efficient approach was to count the primary key, since that is always available in whatever index the query engine could utilize. COUNT(*) used to have to leave the index and retrieve the corresponding row in the table, which was sometimes inefficient. In more modern query planners this is probably no longer the case. COUNT(1) is another variant of this that didn’t force the query planner to retrieve the rows from the table.

    Edit: The query to group by month can be created in a number of different ways. Here is an example:

    SELECT COUNT(1) AS entries, DATE_FORMAT(created_at,'%Y-%c') as month
    FROM wp_frm_items
    WHERE user_id =1
    GROUP BY DATE_FORMAT(created_at,'%Y-%c')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count a list of entries in my database that all have
I have a table: ID name c_counts f_counts and I want to order all
Say I have a column with 10,000 entries. I want to count how many
I want to count all the rows and at the same time list them
I have a table where one or more entries with the same 'id' value
Suppose I want to count the lines of code in a project. If all
We've got a PHP application and want to count all the lines of code
All I want is a pragmatic random number generator in C# so I can
I have 2 tables: Table 1. options_ethnicity with the following entries: ethnicity_id ethnicity_name 1
I was trying to get the count from a table with millions of entries.

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.