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.
我有一个日期列 date CHAR(7) CHARACTER SET LATIN NOT CASESPECIFIC,,比如我有一些值,如 2010-12、2011-10 等。我想将它们更改为日期格式 yyyy/mm 。我该怎么做?谢谢
date CHAR(7) CHARACTER SET LATIN NOT CASESPECIFIC,
只需对 CAST 应用 FORMAT:
SELECT CAST('2010-12' AS DATE FORMAT 'YYYY/MM')
这将返回一个有效日期,并将日期设置为本月 1 日。