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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:45:50+00:00 2026-06-16T20:45:50+00:00

I have created a simple form which users submit. Everything works great but I

  • 0

I have created a simple form which users submit. Everything works great but I recently found that the

SELECT * FROM `Forms` WHERE `Date` BETWEEN '{$startDate}' AND '{$endDate}' 

The column Date is type TEXT. I needed it to be text cause I thought it would be easier to display everything in MM/DD/YY format. Now I dont want to risk changing the data type since the form is working fine.

Example of Date column

01-03-2013
01-04-2013
07-25-2012
08-01-2012
08-01-2012
08-01-2012
08-01-2012

Ex of working Query

SELECT * FROM `Forms` Where `Date` Between '01-08-2012' and '12-12-2012'

Ex of not working Query

SELECT * FROM `Forms` Where `Date` Between '01-08-2012' and '01-04-2013'

Any reason why it would break if the year changes? How can I get it to work even if the year changes.

  • 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-16T20:45:51+00:00Added an answer on June 16, 2026 at 8:45 pm

    you can do it like that

    SELECT * FROM `Forms` 
    WHERE str_to_date(`Date`, '%d-%m-%Y') BETWEEN '2012-01-30' AND '2013-09-29'
    

    DEMO HERE

    EDIT :

    if you want fix your table here how you do

    1. Add a new column of the appropriate DATE data type:

      ALTER TABLE `Forms` ADD `new_date` DATE AFTER `Date`;
      
    2. Use MySQL’s STR_TO_DATE() function to populate that new column with the dates held in the old column:

      UPDATE `Forms` SET `new_date` = STR_TO_DATE(`Date`, '%d-%m-%Y');
      
    3. Drop the old column (and, if so desired, rename the new one in its place):

      ALTER TABLE `Forms` DROP `Date`, CHANGE `new_date` `Date` DATE;
      
    4. Change your application to use this new column.

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

Sidebar

Related Questions

I have created an ajax link(CHTML::ajaxLink) in Yii framework(not ajax form submit button) that
I am a bit confused. I have created a simple form with a one
I have created a simple test form with FormBorderStyle = FixedToolWindow by default and
I have created a simple web app/form using google app engine. the site is
I have a simple form that I would like to validate on form submission.
I have a very simple contact form on my site, Im looking for users
I have a form which allows users to comment on a page, however they
I have created a registration system that uses AJAX to process the form so
Ok. Here is some background: I have created a simple APEX application that is
I'm learning about bean validation. I have created simple form with username and password

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.