M
M
MarkusEfr2019-05-24 22:05:50
PostgreSQL
MarkusEfr, 2019-05-24 22:05:50

How to get dates that match the names of the days of the week in Postgresql?

I have start date, end date and day names.
It is required to find all dates between the beginning and the end that will be on this day.
That 5ce840264e840607376034.jpegis, you need to determine all the dates in the period when it will be Friday or Tuesday.
How can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2019-05-24
@MarkusEfr

select day /*, ... */ 
from tablename 
join lateral generate_series(start_date, end_date, interval '1day') as day on true 
where to_char(day, 'Day') = week_day

if in the forehead and your week_day (which is stored in varchar for a very unclear reason), the spelling coincides with to_char.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question