Search Postgresql Archives

Re: Interval "1 month" is equals to interval "30 days" - WHY?

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

 



BTW there are a much more short version of this:

CREATE OR REPLACE FUNCTION int_equal(interval, interval) RETURNS boolean
IMMUTABLE STRICT LANGUAGE sql AS 
'SELECT $1::text = $2::text';


On Wed, Aug 8, 2012 at 4:51 PM, Albe Laurenz <laurenz.albe@xxxxxxxxxx> wrote:
Then maybe you should use something like this for equality:

CREATE OR REPLACE FUNCTION int_equal(interval, interval) RETURNS boolean
  IMMUTABLE STRICT LANGUAGE sql AS
  'SELECT
        12 * EXTRACT (YEAR FROM $1) + EXTRACT (MONTH FROM $1)
      = 12 * EXTRACT (YEAR FROM $2) + EXTRACT (MONTH FROM $2)
    AND EXTRACT (DAY FROM $1) = EXTRACT (DAY FROM $2)
    AND 3600000000 * EXTRACT (HOUR FROM $1)
        + 60000000 * EXTRACT (MINUTE FROM $1)
        + EXTRACT (MICROSECONDS FROM $1)
      = 3600000000 * EXTRACT (HOUR FROM $2)
        + 60000000 * EXTRACT (MINUTE FROM $2)
        + EXTRACT (MICROSECONDS FROM $2)';


[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