Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
C
Core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 926
    • Issues 926
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • Development
  • Core
  • Issues
  • #423

Closed
Open
Opened Oct 06, 2018 by ken@ken

Upgrading gives error "Incorrect datetime value: '0000-00-00 00:00:00'" in MySQL 5.7

When upgrading CiviCRM from 4.7.12 to 5.3.2 I got the following error ...

PEAR_Exception: "DB Error: unknown error"

  • ERROR TYPE: DB_Error
  • ERROR CODE: -1
  • ERROR MESSAGE: DB Error: unknown error
  • ERROR MODE: 16
  • ERROR USERINFO: UPDATE civicrm_financial_trxn SET trxn_date = NULL WHERE trxn_date = '0000-00-00 00:00:00' [nativecode=1292 ** Incorrect datetime value: '0000-00-00 00:00:00' for column 'trxn_date' at row 1]

The error is raised by 2 lines of SQL in civicrm/CRM/Upgrade/Incremental/sql/4.7.19.mysql.tpl ...

UPDATE civicrm_financial_trxn SET trxn_date = NULL WHERE trxn_date = '0000-00-00 00:00:00';
UPDATE civicrm_contribution SET receive_date = NULL WHERE receive_date = '0000-00-00 00:00:00';

I'm using MySQL 5.7.23. I found a solution which is to cast the DATETIME columns in the WHERE clause to CHAR(20) before comparing to '0000-00-00 00:00:00'.

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
5.7
Milestone
5.7
Assign milestone
Time tracking
None
Due date
None
Reference: dev/core#423