mysql 给出开始和截束日期,每年生成一个记录 同时,批定输出格式


# MySQL  给出开始和截束日期,每年生成一个记录 2024-08-05  2028-8-8  并指输入格式为 2024/9/1 %Y/%c/%e ,一般为 %Y-%m-%d 2023-08-08

  

SELECT DATE_FORMAT(DATE_SUB('开始日期', INTERVAL -pos year), '%Y/%c/%e') as gendate
FROM(
select DM as pos from CT_SystemConst where LB = 1243
and DM <=YEAR('截止日期')- YEAR('开始日期')
) as CT_SystemConst


#结果

2024/9/1
2025/9/1
2026/9/1
2027/9/1
2028/9/1

 

posted @ 2023-09-05 15:56  yongqi-911  阅读(14)  评论(0编辑  收藏  举报