"Andrus" <eetasoft(at)online(dot)ee> writes:
> Jorge,
>
> Thank you very much. Now I try to William Leite Araújo solution by replacing
>
> WHERE (a,b) OVERLAPS (c,d)
>
> with
>
> WHERE ( c BETWEEN a AND b ) OR ( d BETWEEN a AND b )
>
> Is this OK ?
From bare tests this looks OK.
> This requires writing a and b expressions twice. How to avoid repeating
> expressions ?
You can use a function for that and use variables for the four arguments:
CREATE OR REPLACE FUNCTION f_v_same_day_overlaps(date,
date, date, date, out overlaps bool) as
$_$
SELECT (($3 between $1 and $2) or ($4 between $1 and $2));
$_$ language sql;
Be seeing you,
--
Jorge Godoy <jgodoy(at)gmail(dot)com>