这里有什么问题?
SELECT COUNT(*)FROM XXXXX
WHERE(XXXXX
BETWEEN CONVERT_TZ('2016-04-27 00:00:00',' - 0:00',' - 8:00' )AND CONVERT_TZ('2016-04-27 23:59:59',' - 0:00',' - 8:00'))
SELECT COUNT(*)FROM XXXXX
WHERE(XXXXX
BETWEEN'2016-04-27 00:00:00'和'2016-04-27 23:59:59')
两者都显示相同的数量。 CONVERT_TZ有什么问题?
答案 0 :(得分:0)
你在错误的地方有括号。你只用一个参数调用CONVERT_TZ,第一种情况只是'2016-04-27 00:00:00'。
尝试:
SELECT COUNT(*) FROM `XXXXXXX` WHERE `XXXXXXXX` BETWEEN CONVERT_TZ('2016-04-27 00:00:00','UTC','America/Los_Angeles') AND CONVERT_TZ('2016-04-27 23:59:59','UTC','America/Los_Angeles')
请注意,为了使用指定的时区(例如“UTC”和“America / Los_Angeles”),需要填充timezone tables in the mysql system database。