當我們嘗試從日期中提取小時值時,EXTRACT() 函數將給出輸出 0 并帶有警告,如下面給出的示例所示 –
mysql> Select EXTRACT(Hour from '2017-10-20'); +---------------------------------+ | EXTRACT(Hour from '2017-10-20') | +---------------------------------+ | 0 | +---------------------------------+ 1 row in set, 1 warning (0.00 sec) mysql> Show Warnings; +---------+------+----------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------+ | Warning | 1292 | Truncated incorrect time value: '2017-10-20' | +---------+------+----------------------------------------------+ 1 row in set (0.00 sec)
登錄后復制
現在,當我們嘗試從日期中提取分鐘值時,EXTRACT() 函數將給出日期中的世紀值作為輸出,并帶有警告,如下面給出的示例所示 –
mysql> Select EXTRACT(Minute from '2017-10-20'); +-----------------------------------+ | EXTRACT(Minute from '2017-10-20') | +-----------------------------------+ | 20 | +-----------------------------------+ 1 row in set, 1 warning (0.00 sec) mysql> Show Warnings; +---------+------+----------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------+ | Warning | 1292 | Truncated incorrect time value: '2017-10-20' | +---------+------+----------------------------------------------+ 1 row in set (0.00 sec)
登錄后復制
現在,當我們嘗試從日期中提取秒值時,EXTRACT() 函數將給出年份值作為輸出,并帶有警告,如下面給出的示例所示 –
mysql> Select Extract(Second from '2017-10-20'); +-----------------------------------+ | Extract(Second from '2017-10-20') | +-----------------------------------+ | 17 | +-----------------------------------+ 1 row in set, 1 warning (0.00 sec) mysql> Show Warnings; +---------+------+----------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------+ | Warning | 1292 | Truncated incorrect time value: '2017-10-20' | +---------+------+----------------------------------------------+ 1 row in set (0.00 sec)
登錄后復制
嘗試從當前日期獲取時間值(小時、分鐘和秒),即通過在日期位置使用 Curdate() ,我們會得到類似的結果。
以上就是如果我們嘗試僅向 MySQL EXTRACT() 函數提供日期值來提取時間值,會輸出什么?的詳細內容,更多請關注www.92cms.cn其它相關文章!