postgresql documentation gives an example timerange
definition:
CREATE FUNCTION time_subtype_diff(x time, y time) RETURNS float8 AS
'SELECT EXTRACT(EPOCH FROM (x - y))' LANGUAGE sql STRICT IMMUTABLE;
CREATE TYPE timerange AS RANGE (
subtype = time,
subtype_diff = time_subtype_diff
);
SELECT '[11:10, 23:00]'::timerange;
The problem is that when time crosses the day barrier, the range can no longer be used, e.g.
SELECT '[22:00, 06:00]'::timerange;
will produce an error:
ERROR: range lower bound must be less than or equal to range upper bound
LINE 1: SELECT '[22:00, 06:00]'::timerange;
I need to be able to check if the current time is between 22:00 today and 06:00 tomorrow.