mysqlubuntu-12.04convert-tz

convert_tz returns null


I know this sounds stupid, but when I use

SELECT CONVERT_TZ('2004-01-01 12:00:00','UTC','Asia/Jakarta') AS time

it outputs NULL. I'm using MySQL Workbench in Ubuntu 12.04 64 bit, and it works in my other laptop/os (also using MySQL Workbench).


Solution

  • This will happen if you haven't loaded the time zone table into mysql.

    mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
    

    mysql is the name of the built-in database that holds MySQL-specific configuration data.