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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:31:36+00:00 2026-05-11T07:31:36+00:00

I want to get the number of Registrations back from a time period (say

  • 0

I want to get the number of Registrations back from a time period (say a week), which isn’t that hard to do, but I was wondering if it is in anyway possible to in MySQL to return a zero for days that have no registrations.

An example: DATA:

 ID_Profile    datCreate 1   2009-02-25 16:45:58 2   2009-02-25 16:45:58 3   2009-02-25 16:45:58 4   2009-02-26 10:23:39 5   2009-02-27 15:07:56 6   2009-03-05 11:57:30 

SQL:

     SELECT          DAY(datCreate) as RegistrationDate,      COUNT(ID_Profile) as NumberOfRegistrations      FROM tbl_profile     WHERE DATE(datCreate) > DATE_SUB(CURDATE(),INTERVAL 9 DAY)     GROUP BY RegistrationDate     ORDER BY datCreate ASC; 

In this case the result would be:

 RegistrationDate    NumberOfRegistrations 25  3 26  1 27  1 5   1 

Obviously I’m missing a couple of days in between. Currently I’m solving this in my php code, but I was wondering if MySQL has any way to automatically return 0 for the missing days/rows. This would be the desired result:

 RegistrationDate    NumberOfRegistrations 25  3 26  1 27  1 28      0 1       0 2       0 3       0 4       0 5   1 

This way we can use MySQL to solve any problems concerning the number of days in a month instead of relying on php code to calculate for each month how many days there are, since MySQL has this functionality build in.

Thanks in advance

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

    No, but one workaround would be to create a single-column table with a date primary key, preloaded with dates for each day. You’d have dates from your earliest starting point right through to some far off future.

    Now, you can LEFT JOIN your statistical data against it – then you’ll get nulls for those days with no data. If you really want a zero rather than null, use IFNULL(colname, 0)

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

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer SharePoint Wiki out of the box does not support 'full'… May 11, 2026 at 1:02 pm
  • added an answer No. I create labels above the listbox to serve as… May 11, 2026 at 1:02 pm
  • added an answer I very much doubt C will be faster than Perl… May 11, 2026 at 1:02 pm

Related Questions

FromIp contains 192.168.1.1 . I want to get the last number, but I can't
I want to get the MD5 Hash of a string value in SQL Server
I want to get the base 10 logarithm of a Fixnum using Ruby, but
I want to get the size of an http:/.../file before I download it. The
I want to get the size of a drive (or UNC path pointing to
I have a table of vehicles with registration numbers, and want to select a
I want to get the number of rows in my MySQL table and store
I am trying to get the number of students enrolled in courses via a
I'm looking for a way to get the current load (as in Unix: The

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.