Sergei Basharov Sergei Basharov - 4 months ago 35
SQL Question

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

I have

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?


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();