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-01-02,我想获取月份和年份。
2012-01-02
year = 2012 month = 01 day = 02
SELECT MONTH(date_col) AS month , YEAR(date_col) AS YEAR , DAYOFMONTH(date_col) AS day FROM tablename ...
Year() month() dayofmonth()
Year()
month()
dayofmonth()
只需将其从数据库中读取到日期对象中,然后使用日期对象方法来获取您想要的信息