Skip to content

Instantly share code, notes, and snippets.

@dario61081
Created August 9, 2022 17:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dario61081/b7643b0065f695d2df1fbcbc494c206d to your computer and use it in GitHub Desktop.
Save dario61081/b7643b0065f695d2df1fbcbc494c206d to your computer and use it in GitHub Desktop.
listar dinamicamente fecha usando recursividad en mysql
with recursive
p as (
select cast(:fecha_desde as date) fecha_desde ,
cast(:fecha_hasta as date) fecha_hasta
),
fechas as (
select cast(p.fecha_desde as date) fecha
from p
union
select date_add(f.fecha, interval 1 day)
from fechas f, p
where fecha < p.fecha_hasta
)
select *
from fechas;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment