LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-10-2024, 03:24 AM   #1
MakeTopSite
Member
 
Registered: Jan 2021
Location: EU
Distribution: Ubuntu, openSUSE Leap & TW, Devuan, Debian
Posts: 252

Rep: Reputation: 3
mysql: ERROR 1292 (22007): Incorrect date value: '0000-00-00'


Code:
mysql> UPDATE some_table SET some_date_column='2024-04-10' WHERE some_date_column='0000-00-00' ;
ERROR 1292 (22007): Incorrect date value: '0000-00-00' for column 'some_date_column' at row 1
Server version: 8.0.26 MySQL Community Server - GPL

What is please optimal solution ?
 
Old 04-10-2024, 04:41 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,863

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
without details hard to say anything. What is that database, what is that some_table and what is that some_date_column? Anyway, 0000-00-00 is not a valid date. It also may depend on the configuration of the database/table/whatever.
So how do you think we could tell what the optimal solution would be? Probably: some_date_column='1732-11-23'
 
Old 04-10-2024, 05:42 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,866
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Code:
UPDATE some_table SET some_date_column='2024-04-10'
WHERE some_date_column<='0001-01-01';
Or maybe you are referring to NULL-value?
Code:
UPDATE some_table SET some_date_column='2024-04-10'
WHERE some_date_column IS NULL;

Last edited by NevemTeve; 04-10-2024 at 05:43 AM.
 
Old 04-10-2024, 05:48 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

It has to do with sql mode:

https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html

The default has changed in newer versions. After 8.0, the default setting for allow invalid dates changed:

https://dev.mysql.com/doc/refman/8.3...sql-modes.html

The setting you need to change is probably NO_ZERO_DATE.
 
1 members found this post helpful.
Old 04-23-2024, 07:37 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942
... but you should also fix that database! Maybe you temporarily set the configuration to allow "0000-00-00" to be referenced, having determined that the value is actually there. Then, one time, execute a query to UPDATE those values to NULL as they should be. Then, promptly set the configuration back.

(Of course, you will also need to first review the source-code of any applications which now reference that database, so that your change does not break them.)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ModemManager couldn't check support for device `/sys/devices/pci0000:00/0000:00:1c.1/0000:06:00.0` not supported by any plugin George528 Linux - Hardware 3 07-11-2021 08:34 AM
dmesg says:[ 23.443246] nouveau 0000:01:00.0: msvld: unable to load firmware data [ 23.443256] nouveau 0000:01:00.0: msvld: init failed, pixelmatrix Linux - Hardware 2 10-05-2019 10:16 AM
[SOLVED] /etc/sudoers parse error with rgba:0000/0000/0000/dddd dman777 Linux - Security 2 01-23-2015 07:37 PM
LXer: Red Hat: 2014:1292-01: haproxy: Moderate Advisory LXer Syndicated Linux News 0 09-25-2014 01:04 AM
difference between value *value and value * value PoleStar Linux - Newbie 1 11-26-2010 03:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration