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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:38:55+00:00 2026-06-10T19:38:55+00:00

I have a mysql table with a VARCHAR field that stores the dates in

  • 0

I have a mysql table with a VARCHAR field that stores the dates in this format dd/mm/yyyy. This table already have data stored in it, and I am required to sort this data in a descending order. Is this possible?

  • 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-10T19:38:58+00:00Added an answer on June 10, 2026 at 7:38 pm

    The best way to deal with dates is to store then as a date data type.

    You can easily convert the data that is in them now into a date column by adding a column of date datatype, merging the data into it and then re-naming it.

    alter  yourTable add dateColumnName date;
    update yourTable set dateColumnName = STR_TO_DATE(oldDateColumn, '%m/%d/%Y');
    drop column oldDateColumn;
    alter table yourTable change dateColumnName oldDateColumn date;
    

    If you do this, you will be able to do all sorts of complex date stuff (not limited to just sorting a date nicely, or getting the data out in different formats – but calculations, comparisons and much more). You will need to be aware that you will also have to probably change how you insert data into the column – though there are many easy ways to convert a string-date from a CSV or form into a proper date column.

    Edit: As Martin points out, if you have some bum data stored in there now, it might cause problems when converting to a date, but you can find these reasonably easily when doing the update. After the update… query is run, simply run the following:

    select count(*) from yourTable where dateColumnName is null; // Total Problem Count
    select * from yourTable where dateColumnName is null; // Detail
    

    This will show you the rows that didn’t update

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

Sidebar

Related Questions

I have a MySQL database table that has a VARCHAR field storing a date
I've have a date field in my table that stores dates from a form
I have a mysql table structure like that: id int primary key name varchar
I have mysql table that has a column that stores xml as a string.
I have a MySQL table that looks something like this: +-----+------------+ | id |
I have a MySQL table called accounts . Within this table is a field
Suppose I have a simple MySQL table that looks like this: CREATE TABLE `my_table`
Im working on a database that store dates in a varchar(10) mysql field (so
I have a table message in mysql id(bigint) sender(int) receiver(int) message(varchar) 1 42 420
I have MySQL InnoDB table utf-8 encoded. This table has only id and name

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.