从时间字段中删除秒数?

时间:2011-05-02 15:34:44

标签: mysql sql database

如何删除秒数并仅显示hh:mm

字段类型为time。例如:

SELECT opentime, closetime FROM hours

Result:
17:00:00  |  23:00:00
17:30:00  |  23:40:00

1 个答案:

答案 0 :(得分:13)

SELECT
  TIME_FORMAT(opentime, "%H:%i") as opentime,
  TIME_FORMAT(closetime, "%H:%i") as closetime
FROM hours;