MySQL raises error 3229 when you GROUP BY a TIMESTAMP column that can be ambiguous during daylight-saving-time transitions.
MySQL error 3229 ER_GROUPING_ON_TIMESTAMP_IN_DST occurs when a query groups by a TIMESTAMP that overlaps a daylight-saving-time change, making results non-deterministic. Convert the column to UTC or cast to DATE before grouping to resolve the issue.
ER_GROUPING_ON_TIMESTAMP_IN_DST
MySQL error 3229 appears when a query groups by a TIMESTAMP or DATETIME column while the server time zone observes daylight saving time (DST).
Because the same wall-clock time can occur twice during the DST switch, MySQL cannot guarantee deterministic grouping and therefore aborts the statement.
Grouping by a TIMESTAMP that crosses the DST boundary triggers ambiguity when the session or global time_zone is not UTC.
Derived tables, views, DISTINCT, and ORDER BY clauses that implicitly group by temporal columns can also surface the error if those columns hold DST-affected values.
Convert all relevant timestamps to UTC with CONVERT_TZ or set the session time_zone to +00:00 before running the GROUP BY.
Alternatively, cast the column to DATE or YEAR if day-level or year-level granularity is acceptable, removing DST ambiguity.
Analytics dashboards that group sign-up events by hour fail after autumn DST rollover. Switching the query to GROUP BY DATE(CONVERT_TZ(created_at,'SYSTEM','UTC')) restores stability.
Partitioned ETL jobs that aggregate by TIMESTAMP in local time break on DST boundaries. Running the job under SET time_zone='UTC' resolves the crash.
Store and query all timestamps in UTC to make grouping deterministic across time zones.
Always cast to DATE, YEAR, or explicit UTC when grouping temporal data that does not need full timestamp precision.
Errors 1292, 1366, and 1299 also stem from invalid or ambiguous datetime values. Handling time zones consistently prevents them alongside 3229.
Grouping by a TIMESTAMP column in a session using a non-UTC time zone that observes DST.
Aggregations in views or subqueries that implicitly group on temporal columns spanning the DST switch.
Legacy code that mixes server default time_zone with explicit time zone conversions.
ETL batches executed with different time_zone settings between steps, causing inconsistent grouping.
Raised when a datetime string cannot be parsed. Ensure valid formats and correct time zones.
Occurs on invalid character set conversions, including malformed datetime strings.
Appears when an automatic timestamp column conflicts with explicit defaults or time zones.
No. CONVERT_TZ only changes the representation in the query result. Stored values remain unchanged unless an UPDATE is issued.
Not directly. MySQL prevents non-deterministic grouping for data integrity. You must adjust the query or time zone.
sql_mode settings do not influence this check. The server enforces deterministic grouping regardless of mode.
Galaxy highlights non-UTC GROUP BY patterns and suggests safe rewrites with its context-aware AI copilot, reducing run-time failures.