我正在寻找mysql函数date_format
SELECT * FROM bids
WHERE bid_date = DATE_FORMAT('2014-07-13 00:00:00','%Y-%m-%d %H:%i:%s')
我试过以下
SELECT * FROM bids
WHERE bid_date = DATE_FORMAT('00:00:00','%H:%i:%s')
但它无效
答案 0 :(得分:0)
尝试
%T Time, 24-hour (hh:mm:ss)
示例:
DATE_FORMAT(NOW(),'%T')
Output: 11:45:34
答案 1 :(得分:0)
你可以使用HOUR:
SELECT HOUR(Date) from table
答案 2 :(得分:0)
试试这个
EXTRACT()函数用于返回日期/时间的单个部分,例如年,月,日,小时,分钟等。
select EXTRACT(HOUR FROM bid_date) from bids
units:
MICROSECOND
SECOND
MINUTE
HOUR
DAY
WEEK
MONTH
QUARTER
YEAR
SECOND_MICROSECOND
MINUTE_MICROSECOND
MINUTE_SECOND
HOUR_MICROSECOND
HOUR_SECOND
HOUR_MINUTE
DAY_MICROSECOND
DAY_SECOND
DAY_MINUTE
DAY_HOUR
YEAR_MONTH
答案 3 :(得分:0)
SELECT * FROM bids WHERE DATE_FORMAT (bid_date,'%H:%i:%s') = DATE_FORMAT('00:00:00','%H:%i:%s')