0

I would like to get the list of dates from two fields: start and end. I found a case here: Show a list of dates between two dates?

But I would like to have a better solution without going through an intermediary table.

Here is the initial table:

enter image description here

Here is the result I would like to have:

enter image description here

Thank you

1 Answer 1

3

Use generate_series()

select t.id, t.name, t.g.dt::date as start_end
from the_table t
  cross join generate_series(t.date_start, t.date_end, interval '1 day') as g(dt)
order by t.id, g.dt;
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot for the help. it works well. That's exactly what I wanted. Thank.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.