Test project (1 hour), Probable fulltime-work if you pass the test. Write Postgres function

Job ID: 33979809

Budget: $10 – $30 USD

This is a test project to see whether you are qualified to work for us.

What I need is a postgres function with this structure:
CREATE OR REPLACE FUNCTION extract_range(outer_range daterange, inner_range daterange)
RETURNS TABLE
(range daterange) AS $$
$$ LANGUAGE PLPGSQL;

I want to be able to subtract a daterange (inner_range) from another daterange (outer_ranage). The result should be one or two dateranges or a null value.

For example if I have this daterange:
[2018-01-01, 2018-12-31]

and subtract
[2018-03-01, 2018-3-31]

Then I want your pl/pgsql or sql function to return
[2018-01-01, 2018-2-28]
[2018-04-01, 2018-12-31]

Consequentially, if start date or end date of the daterange and the daterange to subtract are equal, then only one daterange will be returned. And if outer and inner dateranage are equal, then null should be returned.

Another way to understand this is: Return the outer_range except for cases when a date is in inner_range.

I am only interested in developers that can finish in 1 hour.

Only bids that start with "postgres function" get accepted.

This project must be delivered by sending a link to dbfiddle.uk (similar to SQLfiddle, but can handle postgres 13). You must implement this so it works in Postgres 13.

You cannnot ask any questions regarding the specifications as they are clear enough to be completed as they are.

The budget is $10
Related categories: PostgreSQL PostgreSQL Programming