Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检索当前年份的最后两位数字-我想从当前年份“2013”中检索“13”。帮我为此提供一个合适的查询
谢谢
试试这个
SELECT DATE_FORMAT(datefield, '%y')
利用DATE_FORMAT
DATE_FORMAT
SELECT DATE_FORMAT(CURDATE(), '%y')
是的,您可以使用 date_format 函数:
SELECT DATE_FORMAT(now(), '%y')
结合Extract 函数和Substring 函数,如:
SELECT Substring(EXTRACT(YEAR FROM '2013-07-02'), 3)
会返回:13
13