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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:11:21+00:00 2026-06-01T01:11:21+00:00

I know that this question is very similar to the question posted here .

  • 0

I know that this question is very similar to the question posted here. But I cannot figure out why I am getting this error. This query syntax is:

update schema.table set date_field = str_to_date(date_field, '%m/%d/%Y') where str_to_date(date_field, '%Y-%m-%d') is null;

The where clause is there to make sure it doesn’t change any dates that are already formatted correctly. It throws this error:

Error Code: 1411. Incorrect datetime value: '01/27/1989' for function str_to_date

I can execute the following query without any problems or errors, this is how i test before I make the changes:

select row_id, date_field, str_to_date(date_field, '%m/%d/%Y'), str_to_date(date_field, '%Y-%m-%d') from schema.table;

This error is strange because when doing this last select statement, if there is improper or unexpected format str_to_date will just return null. I have also used this same syntax (without the where clause) for changing time formats, and there was no problem. If the format was unexpected or incorrect it would just update that field with a null value. I don’t know what is up with this 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-06-01T01:11:22+00:00Added an answer on June 1, 2026 at 1:11 am

    It is because of the WHERE clause. What is the current data in this column? Is it that some are in Y-m-d and some are m/d/Y? If so, you could use a regex for your WHERE clause –

    UPDATE schema.table
    SET date_field = STR_TO_DATE(date_field, '%m/%d/%Y')
    WHERE date_field REGEXP('^[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}$');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there is this question that is very similar, but I wanted to
I know this is very similar to a previous question that I had posted,
I know that this is a repeated question. I have found very similar questions
I know that this sort of question has been asked here before, but still
So I know that there is a very similar question to this all over
[I already posted something very similar but the question wasn't good, here is what
I know this question is very similar to this one, but I feel its
I know that very similar question was posted some time ago and it was
I know that there is a previously posted question that is very similar to
I know that there's a very similar topic for this question, however I'm trying

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.