I know we can use Postgres's generate_series() function to produce a list of timestamps. Can we do the same to produce a list of time ranges directly without having to manually convert generated timestamps into time ranges like so?

SELECT tstzrange(
   time_stamp + '1 days'
) AS time_range
FROM generate_series(
   '1 days'
) tmp(time_stamp);
  • Hoping to avoid having to call tstzrange() in the SELECT clause to not repeat the “1 days” offset twice which in my real example is a more complicated function.
    – eliangius
    Jun 7, 2022 at 11:35

1 Answer 1


Up to Postgres 14, there is no variant of generate_series() doing that. Check with:

SELECT oid::regprocedure   AS function_signature
     , prorettype::regtype AS return_type
FROM   pg_proc
where  proname = 'generate_series';


You can produce timestamp or timestamptz, but not date or tstzrange.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.