MySQL statement:
insert into `banners`
(`path`, `app_id`, `enabled`, `from_date`, `to_date`, `updated_at`, `created_at`)
values
('banners/example.png', 'com.example.ccp_attacker', 1, '2000-01-01 00:00:00', '2099-12-31 00:00:00', '2100-06-04 00:00:00', '2100-06-04 00:00:00')
generates error #1292 - Incorrect datetime value: '2100-06-04 00:00:00' for column 'updated_at' at row 1
Why 2100-06-04 00:00:00 is not a valid time?
With the STR_TO_DATE() function, the previous INSERT statement won't cause an error: INSERT INTO example (last_update) values(STR_TO_DATE("10-17-2021 15:40:10", "%m-%d-%Y %H:%i:%s")); And that's how you can fix the error Incorrect datetime value in MySQL.
You just need to go to the Wamp panel, then to MySQL, then to settings and change the mode to sql-mode: none. (essentially disabling the strict mode) The following picture illustrates this.
Introduction to MySQL DATE data type This format is fixed and it is not possible to change it. For example, you may prefer to use mm-dd-yyyy format but you can't. Instead, you follow the standard date format and use the DATE_FORMAT function to format the date the way you want. MySQL uses 3 bytes to store a DATE value.
The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts.
MySQL date does not excees 2038. This is a very old problem and for some reason they are not solving it. The max value for acceptable date in MySQL is 2038
. When I faced this issue I saved the date in MySQL as varchar
and later converted it to date in the business logic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With