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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:14:26+00:00 2026-06-10T23:14:26+00:00

Hey i have a little problem when i’m trying to get count of rows

  • 0

Hey i have a little problem when i’m trying to get count of rows from table, where date is BETWEEN 2012-09-01 AND 2012-09-32…

Could you please tell me where’s the problem?

$month = date(m);
$year = date(Y);
$day_start = '01';
$day_end = '32';

$from = $year.'-'.$month.'-'.$day_start;
$till = $year.'-'.$month.'-'.$day_end;

$result1 = $mysqli->query("SELECT COUNT(id) FROM `dreams` WHERE dream_state='dream' AND date BETWEEN $from AND $till");
$row1 = $result1->fetch_row();
$this_dream = $row1[0]; 

i’ve tryed to convert the string to time and from time to date like this:

$from = strtotime($from);
$from = date("Y-m-d",$from);

$till = strtotime($till);
$till = date("Y-m-d",$till);

but still doesn’t work, so any ideas?

Thank you.

  • 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-10T23:14:28+00:00Added an answer on June 10, 2026 at 11:14 pm

    First of all, your date column needs to be some kind of date datatype, like DATE or TIMESTAMP.

    Second, you need to use valid dates for comparison. September 32 is no good. When MySQL tries to interpret that date it gets NULL. All comparisons between real values and NULLs come up false. So, you get an empty result set.

    Third, BETWEEN is terrible for date comparison ; it often fouls up the end — the last day — of the range.

    I suggest you use a query like this. Notice that the second date comparison to is the day after the end of the range you want.

    $month = date(m);
    $year = date(Y);
    $day_start = '01';
    $from = $year.'-'.$month.'-'.$day_start;
    
    $result1 = $mysqli->query("SELECT COUNT(id) 
                                 FROM `dreams`
                                WHERE dream_state='dream' 
                                  AND date >= '$from'
                                  AND date < '$from' + INTERVAL 1 MONTH");
    $row1 = $result1->fetch_row();
    $this_dream = $row1[0]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys! I have this little problem: I have one ViewController which adds 2
Hey most of my issue has been solved but i have little problem This
Hey guys, I have a little problem with a simple ajax request. I can't
Hey all, i'm having a little problem with ksoap2 and getting response i have
hey i get lots of image from RSS Than i have to display all
hey guys, somehow i can't find the solution for my little problem. i have
Hey guys, just another little problem here! Trying to write a quiz for a
Hey guys I have a little issue here. I have a panel where I
Hey i have been looking around and i cant find a way to get
Hey I have downloaded one of the xml editors from some site. But don't

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.