2

When doing a regular:

select convert_tz(now(), "UTC", "Europe/London")

directly on a MariaDB server, it will produce:

+-------------------------------------------+
| convert_tz(now(), "UTC", "Europe/London") |
+-------------------------------------------+
| 2013-03-07 16:01:32                       |
+-------------------------------------------+

But if done through ruby 1.8.7 or 1.9.3 width:

q = 'select convert_tz(now(), "UTC", "Europe/London")'
ActiveRecord::Base.connection.select_all(q)

it will produce:

"convert_tz(now(), \"UTC\", \"Europe/London\")" => nil

Do the same against a MySQL setup:

q = 'select convert_tz(now(), "UTC", "Europe/London")'
ActiveRecord::Base.connection.select_all(q)

results in:

"convert_tz(now(), \"UTC\", \"Europe/London\")" => "2013-03-07 16:05:14"

Now tested in MySQLWorkbench and the same bad result occurs there, null is returned instead of the converted time.

So I guess it's something in MariaDB or?

fedorqui
  • 275,237
  • 103
  • 548
  • 598
renemadsen
  • 161
  • 1
  • 9

2 Answers2

1

You are likely missing the timezone info. You can generate this by using the mysql_tzinfo_to_sql utility or downloading the tables from the mysql dev site.

If you're on Mac or Linux, then the following is likely to work for you (might have to update the location of your zoneinfo)

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot -Dmysql
0

Upgrading to 5.5.29-MariaDB solved the problem, so I guess it was related to 5.5.28.

renemadsen
  • 161
  • 1
  • 9