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

  • Home
  • SEARCH
  • 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 392115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:07:38+00:00 2026-05-12T16:07:38+00:00

Essentially I need to retrieve some account information from the dbase table where they

  • 0

Essentially I need to retrieve some account information from the dbase table where they have a client of the client that has been passed via GET, and the account placement date (dateplaced) is between the start and end dates passed from calendar fields again via GET.

The query below returns no rows. I have verified that the SELECT and FROM portions of the query work as intended, and the client select from GET works fine, so that leaves the date issues. “dateplaced” is stored in the database as a varchar in “dd/mm/yyyy” format. Upon researching I’ve found that mysql wants dates in “yyyy-mm-dd” format. I have pieced together the two parts of the between comparison from GET data, and am fairly certain they are formatted correctly. I tried just plainly using “dateplaced” instead of str_to_date() and it didn’t work, so I tried str_to_date() as shown below, but it still doesn’t work.

Can anyone spot my problem here? This is driving me nuts.

$query = mysql_query("SELECT accountnumber, firstname, middlename, lastname, currentbalance FROM dbase WHERE clientname = '" . $_GET['client'] . "' AND str_to_date(dateplaced, '%Y-%m-%d') BETWEEN '" . $_GET['calendar_start_year'] . "-" . $_GET['calendar_start_month'] . "-" . $_GET['calendar_start_day'] . "' AND '" . $_GET['calendar_end_year'] . "-" . $_GET['calendar_end_month'] . "-" . $_GET['calendar_end_day'] . "' ORDER BY lastname") or die(mysql_error());
  • 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-12T16:07:39+00:00Added an answer on May 12, 2026 at 4:07 pm

    str_to_date() takes the format of the existing string, not the desired string. So you need
    str_to_date(dateplaced, '%d/%m/%Y') to get Y-m-d.

    Do your date creation outside the query. It’s easier to debug.

    $clean_name=mysqli_real_escape_string($_GET['client']);
    $start_date=date_create("{$_GET['calendar_start_year']}-{$_GET['calendar_start_month']}-{$_GET['calendar_start_day']}")->format('Y-m-d');
    $end_date=date_create("{$_GET['calendar_end_year']}-{$_GET['calendar_end_month']}-{$_GET['calendar_end_day']}")->format('Y-m-d');
    
    $q="SELECT accountnumber, firstname, middlename, lastname, currentbalance 
    FROM dbase 
    WHERE clientname = '{$clean_name}' 
      AND str_to_date(dateplaced, '%d/%m/%Y') BETWEEN '$start_date' AND '$end_date' 
    ORDER BY lastname;
    

    PS, clean all your variables. There may be quote marks or other characters that need to be escaped (or evil hacker attempts). mysqli_real_escape_string() is what you should use.

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

Sidebar

Related Questions

I have essentially a survey that is shown, and people answer questions a lot
Essentially I need a count of each Entries Comments: SELECT e.*, COUNT(c.id) as comments
Essentially, I have to get a flat file into a database. The flat files
I have what is essentially a jagged array of name value pairs - i
So What I'm essentially trying to do is have something happen 70% of the
Essentially I want to know if in VB.NET 2005 if using a sqlcommand and
Essentially the only thing I can deploy to my deployment machine is a JAR
So essentially does margin collapsing occur when you don't set any margin or padding
I essentially want to spider my local site and create a list of all
There are essentially 2 places to define JavaScript functions in Grails, directly in a

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.