我想根据当前时间获取最近六个月的日期,请问以下SQL中的方法在MYSQL中改怎么写,求大神指教

SELECT CONVERT(varchar(7), GETDATE(), 20) AS yearMonth UNION
SELECT CONVERT(varchar(7),DATEADD(m, - 1, GETDATE()), 20) AS time UNION
SELECT CONVERT(varchar(7),DATEADD(m, - 2, GETDATE()), 20) AS time UNION
SELECT CONVERT(varchar(7),DATEADD(m, - 3, GETDATE()), 20) AS time UNION
SELECT CONVERT(varchar(7),DATEADD(m, - 4, GETDATE()), 20) AS time UNION
SELECT CONVERT(varchar(7),DATEADD(m, - 5, GETDATE()), 20) AS time

select date_format( now( ) , ‘%Y%m’ ) , date_format(date_sub(now(),interval 6 month) , ‘%Y%m’ )
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答