Search Postgresql Archives

Re: Why overlaps is not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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
}

' ;


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux