I want to notify users that the server is undergoing maintenance and provide them with the remaining time until the maintenance is completed. However, I'm having trouble with the MySQL query.
This is the query I use:
SELECT TIMESTAMPDIFF(SECOND, NOW(), STR_TO_DATE(JSON_EXTRACT(VALUE_, '$.END_DATE'), '%Y-%m-%d %H:%i:%s')) AS SECONDS_LEFT FROM SETTINGS WHERE KEY_ = 'MAINTENANCE'
Unfortunately, the query always returns null values.
The following is the table structure and data for your reference.
CREATE TABLE `settings` ( `KEY_` char(50) COLLATE utf8_unicode_ci NOT NULL, `VALUE_` json NOT NULL, UNIQUE KEY `KEY_` (`KEY_`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
maintain |
Can you help me figure out what I might have missed?
Thank you in advance.
solved.