Sergei Basharov Sergei Basharov - 1 year ago 80
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?

Answer Source

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();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download