IT序号网

mysql 获取最近一个月每一天

developer 2021年06月14日 数据库 258 0

   
    
  1. select date_add( curdate(), interval( cast(help_topic_id as signed integer) - 30) day) day
  2. from mysql.help_topic
  3. where help_topic_id < day( last_day( curdate()))
  4. order by help_topic_id

2019-07-03更新进一步格式化版

 
SELECT 
	DATE_FORMAT( date_add( curdate( ), INTERVAL ( cast( help_topic_id AS signed INTEGER ) - 30 ) DAY ) , '%m/%d' ) DAY 
FROM 
	mysql.help_topic  
WHERE 
	help_topic_id < DAY ( last_day( curdate( ) ) )  
ORDER BY 
	help_topic_id 
原文地址:https://blog.csdn.net/qq_29384639/article/details/89563852

评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!