Home > database >  Mysql for a period of time
Mysql for a period of time

Time:10-18

Build (not table) to implement in mysql, input parameters, the effect of the 2019-10-18 and 2019-10-18 output below
The 2019-10-18
The 2019-10-17
The 2019-10-16
The 2019-10-15
The 2019-10-14
The 2019-10-13
2019-10-12

CodePudding user response:

Use DateDiff function that first date difference, in circulation plus one with Date_ADD function is not ok

CodePudding user response:

 with recursive tab1 (dt) as (
The select str_to_date (' 2019-10-18 ', '% % Y - m - % d')
Union all
Select adddate (t1), dt - 1) the from tab1 t1 where datediff (str_to_date (' 2019-10-12 ', 'Y - m - % d % %), t1, dt) & lt; 0
)
Select * from tab1;
  • Related