Sergei Basharov Sergei Basharov - 19 days ago 6
SQL Question

How can I get start and end dates of daterange in Postgres?

I have

daterange
type column in a table. I want to select all rows which have end date in their daterange that is in the future.

Can I somehow extract start and end values of the daterange in a query?

Answer

I suppose, you can use upper(anyrange) function to get this value. According to the docs.

Something like:

SELECT * FROM table_name
WHERE upper(daterange_type_colum) > current_date();