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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:17:05+00:00 2026-05-16T09:17:05+00:00

I have a php page which allows a user to sort pieces of information

  • 0

I have a php page which allows a user to sort pieces of information by several factors. A new requirement is to sort by "all items which have been registered in the last 15 days". I store my dates in the MYSQL table as mm/dd/yyyy.

The information is passed and picked up on the same page using the $_GET variable but I am unable for some reason to get the code to work. I have looked on numerous website but am unable to find a solution that works.

Ultimately, the script would work as follows:

select all persons who’s KDATE is within 15 days of today’s date (e.g., if today is 8/19/2010, everybody who registred from 8/04/2010 and on would appear).

My script so far (which does not work) is:

if (isset($_GET['date'])) {
     $query = "SELECT * 
                 FROM persons 
                WHERE DATE_SUB(CURDATE(),INTERVAL 15 DAY) <= KDATE 
             ORDER BY KDATE ASC";
}

Update 1:

KDATE IS TEXT – i apologize but the KDATE is stored as TEXT

Update 2:

The answer provided by Colin solved my issue. I will look into trying to convert the data into datetime format but am hoping the group can provide realistic benefits of doing so.

Thank you all again

  • 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-16T09:17:06+00:00Added an answer on May 16, 2026 at 9:17 am

    First of all, it’s a really bad idea to use VARCHAR instead of DATE if you want a collumn with dates only.

    If you want to use a string as a date, you’ll need to convert it with STR_TO_DATE() and you might wan’t to use those instructions to correctly format your date.

    This should do it:

    SELECT * 
    FROM persons 
    WHERE DATE_SUB(CURDATE(),INTERVAL 15 DAY) <= STR_TO_DATE(KDATE, "%c/%d/%Y")
    ORDER BY STR_TO_DATE(KDATE, "%c/%d/%Y") ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which basically allows an admin user to create manager user
I have a PHP-generated page which is displaying some data about a set of
I'd like to have a page in php that normally displays information based on
Let's say I have a page called display.php and the user is viewing display.php?page=3
i have a form which allows the user to upload some files to a
I have a form which allows users to comment on a page, however they
I have a form which has two inputs. The first input allows a user
I have a php page that displays rows from a mysql db as a
I have a particular PHP page that, for various reasons, needs to save ~200
I have a site with URLs like this: http://domain.co.uk/subdir/page.php I have redesigned the site

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.