mysql 查询指定月份的每一天日期

mysql 查询指定月份的每一天日期 日期:2023-02 ,传入SQL 2023-02-01

	SELECT
	date_add(
	DATE_ADD( DATE_FORMAT( '2023-02-01', '%Y-%m-%d' ), INTERVAL - DAY ( DATE_FORMAT( '2023-02-01', '%Y-%m-%d' ) ) + 2 DAY ),
	INTERVAL ( cast( help_topic_id AS signed INTEGER ) - 1 ) DAY 
	) DAY 
FROM
	mysql.help_topic 
WHERE
	help_topic_id < DAY ( last_day( DATE_FORMAT( '2011-02-01', '%Y-%m-%d' ) ) ) 
ORDER BY
	help_topic_id

查询当月的每一天,由1号开始,到当月结束日期


SELECT
date_add(DATE_ADD(curdate(), INTERVAL - DAY(curdate()) + 2 DAY), INTERVAL (cast( help_topic_id AS signed INTEGER ) - 1 ) DAY ) DAY 
from mysql.help_topic
where help_topic_id  < day(last_day(curdate()))
order by help_topic_id

查询当天起未来一个月(30天)的每一天 

select 
date_add(curdate(), interval(cast(help_topic_id as signed integer) ) day) day
from mysql.help_topic
where help_topic_id  < day(last_day(curdate()))
order by help_topic_id

查询当前时间24小时每一小时时间

SET @i=-1;
SELECT DATE_SUB( NOW(),INTERVAL ( (@i:=@i+1) ) HOUR ) AS 'time'
FROM  mysql.help_category 
WHERE @i<23

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值