From: | "Ian Harding" <iharding(at)destinydata(dot)com> |
---|---|
To: | Andrus <eetasoft(at)online(dot)ee> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why overlaps is not working |
Date: | 2006-11-13 15:43:52 |
Message-ID: | 725602300611130743v1bd4c477kb25602673f658453@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
> If first period end and second period start dates are the same, I need that in this case expression
> returns true.
> Is it possible to implement this using OVERLAPS operator ?
>
I think the best workaround is a function of some kind in whichever
language you choose. I think you could actually clobber overlaps()
but I chose to give mine a different name. In my world, all date
ranges have a start, but can have an indefinite end (null).
CREATE OR REPLACE FUNCTION "isoverlap" (date,date,date,date) RETURNS
boolean LANGUAGE pltcl AS '
set d1 [clock scan $1]
set d3 [clock scan $3]
if {[string length $2] == 0} {
set d2 0
} else {
set d2 [clock scan $2]
}
if {[string length $4] == 0} {
set d4 0
} else {
set d4 [clock scan $4]
}
if {($d2 >= $d3 && ($d1 <= $d4 || !$d4)) ||
($d1 <= $d4 && ($d2 >= $d3 || !$d2)) ||
(!$d2 && !$d4)} {
return true
} else {
return false
}
' ;
From | Date | Subject | |
---|---|---|---|
Next Message | Matthew T. O'Connor | 2006-11-13 17:43:29 | Re: AutoVacuum on demand? |
Previous Message | Chris Browne | 2006-11-13 15:30:36 | Re: Request for replication advice |