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.
「2012年12月」のような日付になり、「2012-12-01」のような日付に変換したいと思います。STR_TO_DATE('Dec 2012'、'%b%Y')を使用していますが、最終的には2012-12-00のようになります。月の初日に設定するためのアイデアはありますか?
前もって感謝します。
DATE_FORMAT(STR_TO_DATE('Dec 2012','%b %Y'), '%Y-%m-01')
これを試して:
SELECT STR_TO_DATE(CONCAT('01 ', 'Dec 2012') ,'%d %b %Y');
また
SELECT DATE_ADD(STR_TO_DATE('Dec 2012','%b %Y'), INTERVAL 1 DAY);