How to Fix MySQL Error 3912 (ER_GROUPING_ON_TIMESTAMP_IN_DST)
You get mysql error 3912 when a query groups timestamp values in a timezone with daylight saving time. You can fix this issue by changing the session or query timezone to UTC. MySQL flags this issue with the symbol ER_GROUPING_ON_TIMESTAMP_IN_DST and SQLSTATE HY000. The engine warns that grouping on time values is not predictable when clocks shift. It stops or warns the query so your reports do not return wrong group totals. What causes mysql error 3912 in the database engine Timezones that
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mysql error 3912 when a query groups timestamp values in a timezone with daylight saving time. You can fix this issue by changing the session or query timezone to UTC.
MySQL flags this issue with the symbol ER_GROUPING_ON_TIMESTAMP_IN_DST and SQLSTATE HY000. The engine warns that grouping on time values is not predictable when clocks shift. It stops or warns the query so your reports do not return wrong group totals.
What causes mysql error 3912 in the database engine
Timezones that use daylight saving time change their clocks twice a year. In the spring, the clock jumps ahead by one hour. In the fall, the clock repeats the same hour twice. This repeated hour creates a major problem for database grouping logic.
MySQL stores timestamp columns in UTC on disk. When you run a query, the engine converts those stored values to your active timezone. Two different UTC moments in the fall can map to the exact same local clock time. If your query groups by a converted timestamp expression, the engine hits a conflict.
The database cannot tell if those two moments belong in one group or two. The result becomes unpredictable across different runs or server settings. To protect data accuracy, MySQL triggers error code 3912 and asks you to use UTC instead.
How to diagnose the timezone conflict in production
First, check which queries fail or log warnings in your database logs. Look for reporting queries that group rows by time columns or date functions. Next, check the global and session timezone settings on your MySQL server.
Many servers inherit their local timezone from the host operating system. If the host uses a named regional zone like America or Europe, daylight saving rules apply. Client apps might also set a local timezone right after they log in to the database.
Just-in-Time Access + Single Sign-On (SSO): architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Check the schema of the tables in the failing query. This error affects timestamp columns because MySQL converts them based on the active timezone. Date and datetime columns do not convert timezones on read, though casting functions can still trigger the check.
How to fix the grouping failure safely
The safest fix is to run your grouping queries in the UTC timezone. UTC never shifts for daylight saving time, so every second of the year is unique. You can set the session timezone to UTC before running your report.
Do not grant admin roles to app users just to change global server variables. Keep global settings locked down and change only the session timezone for the specific reporting job. You can also update your app connection pool to use UTC for all sessions.
If users need local time in their final charts, convert the time values in the app layer. Let the database group the raw records in UTC first. Then format the grouped output for the user's screen after the query finishes.
Never disable strict SQL modes in production to hide this message. Turning off safety checks allows silent data errors in financial or operational reports. Fixing the timezone in the session keeps your safety rules intact and your totals accurate.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Why does MySQL warn about grouping timestamps in local timezones?
Daylight saving time repeats one hour in the fall. Two distinct UTC timestamps can look identical in local time, making group totals inaccurate.
Does switching the session to UTC change stored table data?
No, changing the session timezone does not alter data on disk. MySQL already stores timestamp columns in UTC and only changes how it reads them.
Can I fix this error without changing the global server timezone?
Yes, you can set the timezone to UTC at the session level before running the query. This fixes the query without affecting other apps on the server.
Related guides
In this post