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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:24:11+00:00 2026-06-04T07:24:11+00:00

I have a date field (tinytext) holding date information in format of dd-mm-yy e.g

  • 0

I have a date field (tinytext) holding date information in format of “dd-mm-yy” e.g 07-01-90. Using a mysql query I want to change it to yyyy-mm-dd date format. I tried the code below but nothing happens.

mysql_query("UPDATE Table SET date=STR_TO_DATE('date','%Y,%m,%d')");
  • 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-04T07:24:12+00:00Added an answer on June 4, 2026 at 7:24 am

    You’re using the correct function STR_TO_DATE(str,format) to achieve the goal, but you’re making two mistakes:

    1. In your query the format argument does not match the string expression format. You said it’s in dd-mm-yy format while you passed %Y,%m,%d (comma separated) to the format argument. The query will return a “incorrect datetime value” error. You should use %d-%m-%Y.
    2. You can’t change data type of a column on the fly, by setting different type of the value being passed. You have to first update the values and then change data type for column.

    So, summarizing:

    mysql_query("UPDATE `Table` SET `date` = STR_TO_DATE(`date`, '%d-%m-%Y')");
    mysql_query("ALTER TABLE `Table` CHANGE COLUMN `date` `date` DATE");
    

    Additionally, consider switching to the recommended PDO extension in place of old and slowly deprecated mysql extension.

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

Sidebar

Related Questions

I have a date field in a query and I do want to get
Good morning, mysql query which displays cases that have a date field completed &
I have a date field in flex and have the format set to YYYY-MM-DD.
I have a date field in php which is using this code: $date =
I have date field in my MySQL DB and three fields (yyyy-mm-dd) in my
I want a Django model to have a date field in which the year,
I have a table A with a date field. I want to make a
I have a MySQL table where there is a 'date_added' (date) field, 'time_added' (time)
I have an array that I would like to sort using a date field
I have date in dd/mm/yyyy format. How can I store it in a database,

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.