2

I have a problem with saving values of type tsrange in PostgreSQL when only one of the intervals is in daylight saving time and the interval is less than 1 hour long.

For example I want to save a 45 minutes long time range ["2013-03-09 01:30:00","2013-03-09 01:15:00"], however I'm getting an error range lower bound must be less than or equal to range upper bound

Is there a way to save these kind of time ranges into PostgreSQL using tsrange type?

Peter
  • 580
  • 8
  • 22

1 Answers1

1

The input must be already "timezoned" then cast to timestamp without time zone

select tsrange(
    ('2013-02-17 01:30:00'::timestamp at time zone 'BRST')::timestamp,
    ('2013-02-17 01:15:00'::timestamp at time zone 'BRT')::timestamp
);
                    tsrange                    
-----------------------------------------------
 ["2013-02-17 00:30:00","2013-02-17 01:15:00")
Clodoaldo Neto
  • 118,695
  • 26
  • 233
  • 260