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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:31:08+00:00 2026-05-28T16:31:08+00:00

Hey guys i have two date inputs containing three dropboxes for day,month and year

  • 0

Hey guys i have two date inputs containing three dropboxes for day,month and year each.
day has a name d1, month=m2,year=y1 and similarly for the second date input its d2,m2 and y2

i’m trying to query the database for information between a particular date range.

  $date1=date("Y-m-d", mktime(0, 0, 0, $_POST['m1'], $_POST['d1'],$_POST['y1']));
  $date2=date("Y-m-d", mktime(0, 0, 0, $_POST['m2'], $_POST['d2'],$_POST['y2']));

  echo $date1." and ".$date2;

$query="SELECT *FROM FDB where time BETWEEN ".$date1." and ".$date2;
$f = mysql_query($query) or die(mysql_error());
$nfiles= mysql_num_rows($f);

$query="SELECT *FROM usr where created BETWEEN ".$date1." and ".$date2;
$f = mysql_query($query) or die(mysql_error());
$nus= mysql_num_rows($f);

It is showing an error on the line below

$query="SELECT *FROM history WHERE ACTIVITY='Logged In' where CAST(FLOOR(CAST(time AS FLOAT))AS DATETIME) between ".$date1." AND ".$date2;

The error is

          You have an error in your SQL syntax; check the manual that corresponds to  your MySQL server version for the right syntax to use near 'where CAST(FLOOR(CAST(time AS FLOAT))AS DATETIME) between `2011-01-01` AND `2012' at line 1

How do I need to change my code so that I don’t get the error any longer?

  • 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-28T16:31:09+00:00Added an answer on May 28, 2026 at 4:31 pm

    You got 2 WHERE clauses on your code.

    Try this way

    $query="SELECT * FROM history 
            WHERE ACTIVITY='Logged In' 
                AND CAST(FLOOR(CAST(time AS FLOAT))AS DATETIME) 
                between ".$date1." AND ".$date2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, i have a probably rather simpel problem: my website has two layers:
Hey guys I have a query that currently finds the latest comment for each
Hey guys, so I have two models in my project, grinders, and votes. So
Hey guys. I have a question. I have two different arrays with different structure
hey guys what I am trying to do is have two edit boxes for
Hey guys. I have a method that gets called each second which I want
Hey guys, so I have two arrays $names = array('jimmy', 'johnny', 'sarah'); $ages= array('16',
Hey guys I need some help with this: I have two view controllers, let's
hey guys I have two divs- with id=form1 which is inline and the other
Hey guys, quick question. I have a table of messages. There are two types

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.