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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:36:14+00:00 2026-06-12T23:36:14+00:00

I have some invalid dates in my table. I’ve heard I can disable strict

  • 0

I have some invalid dates in my table. I’ve heard I can disable strict mode or use sql_mode ALLOW_INVALID_DATES which doesn’t work (have confirmed with select @@global.sql_mode and restarted server).

My question is, can I not fix these ‘invalid’ dates? I’m not going to be able to disable strict mode on every server.

select * from table
>> Mysql2::Error: Invalid date: 1900-00-00

mysql --version
mysql  Ver 14.14 Distrib 5.1.61, for debian-linux-gnu (i686) using readline 6.1

mysql> select @@global.sql_mode;
+---------------------+
| @@global.sql_mode   |
+---------------------+
| ALLOW_INVALID_DATES |
  • 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-12T23:36:15+00:00Added an answer on June 12, 2026 at 11:36 pm

    It looks like your error message is coming from your MySQL client, not the server. So, setting server strict mode isn’t going to help you display these dates with this client.

    It seems like you have some 2012-09-31 or 2013-02-29 style dates in your data. They’re correctly formatted but otherwise are wrong. In pre 5.0.2 versions of MySQL these didn’t get caught correctly going into your data. Now, your server, set to ALLOW_INVALID_DATES isn’t gagging on them, but instead is converting them to ‘0000-00-00’. And the client is gacking on them.

    Your first step to cleaning this up is to identify the offending rows. You could try this.

    First, turn on ALLOW_INVALID_DATES.

    Then, run this query to look around in your table. Don’t use SELECT *.

      SELECT col,col,col,DATE_FORMAT(datecol,'%Y-%m-%d') 
        FROM mytable
       ORDER BY DATE_FORMAT(datecol,'%Y-%m-%d') 
    

    Try to figure out from the result set which dates are garbage. They may be placed first in this select statement, but you’re going to have to muck around a little bit to find them.

    Next, figure out how you want to fix them. Delete the rows? Change the date to 1941-12-07, 2003-03-20, or 2022-02-24 (dates that live in infamy)? We can’t tell you what you need to do here.

    Then, fix them. If there are only one or two, fix them one by one.

      UPDATE mytable
         SET datecol='whatever replacement date'
       WHERE id='the id of the offending row.'
    

    or

      DELETE FROM mytable
            WHERE id='the id of the offending row.'
    

    If there are thousands of them, you could bulk fix them with something like this. *But don’t do this without first working through the problem very carefully on a test server. If you make a mistake you will trash your table.*.

      UPDATE mytable
         SET datecol='whatever replacement date'
       WHERE '0000-00-00' = DATE_FORMAT(datecol,'%Y-%m-%d')
    

    After you’ve finished correcting your problems, go back and do your SELECT *, to make sure you got them all.

    Then disable ALLOW_INVALID_DATES and never re-enable it again.

    That should clean up the mess. Notice that real-world data always have some rows that aren’t perfect in it.

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

Sidebar

Related Questions

I have some data (produced by a legacy application) that I know is invalid
I have some table: Title 1 | Title 2 | Title 3 | --------------------------------------------------
I have created a table in Oracle 10g and trying to insert some rows
I have some dates I have to represent in an XML file in a
I have a html table in my ASPX page and would like to use
I have a table with domains and their start dates. I want when I
We have a table which has a DATE column d. I'd like to get
I have some specs, written in RSpec, that test various models. I use Factory
I have some data loaded as a np.ndarray and need to convert it to
I have some arbitrary pixel data that I want to save as a PNG.

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.