Mysql str_to_date with convert_tz returns NULL

574 Views Asked by At

The following MYSQL query returns a date as expected:

select str_to_date('Thu, 13 May 2021 10:40:00 +0000',
                     '%a, %d %b %Y %H:%i:%s +0000') the_date;
+---------------------+
| the_date            |
+---------------------+
| 2021-05-13 10:40:00 |
+---------------------+
1 row in set (0.00 sec)

The date value string is from another data source with the timezone UTC.

I need to ensure this is correctly adjusted for London (GMT in Winter, BST or GMT+1 in Summer). For this I am trying to use convert_tz as follows, but the result is NULL:

select convert_tz(str_to_date('Thu, 13 May 2021 10:40:00 +0000',
                              '%a, %d %b %Y %H:%i:%s +0000'),
                  'UTC', 'Europe/London') the_date;
+----------+
| the_date |
+----------+
| NULL     |
+----------+
1 row in set (0.00 sec)

Why NULL?

0

There are 0 best solutions below