4100
MariaDBWARNINGCriticalHIGH confidence

YEAR(4) with zero date is deprecated

Production Risk

Low — Current behavior is preserved, but future MySQL versions may reject zero dates.

Why it happens
  1. 1A YEAR column stores or defaults to the value '0000'.
  2. 2NO_ZERO_DATE sql_mode is disabled, allowing zero years to be inserted.

Fix 1

Replace zero YEAR values with valid data

Replace zero YEAR values with valid data
UPDATE t SET year_col = NULL WHERE year_col = 0;

Why this works

Replace zero-year values with NULL or a valid year to prepare for stricter enforcement.

Fix 2

Enable NO_ZERO_DATE in sql_mode

Enable NO_ZERO_DATE in sql_mode
SET SESSION sql_mode = CONCAT(@@sql_mode, ',NO_ZERO_DATE');

Why this works

Prevents new zero date values from being inserted.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 4100 ER_WARN_DEPRECATED_YEAR4_ZERO_DATE

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors