RE: Comparing dates in 3.0 - Mailing list pgsql-general

From Francis Solomon
Subject RE: Comparing dates in 3.0
Date
Msg-id NEBBIFFPELJMCJAODNPKOECKCDAA.francis@stellison.co.uk
Whole thread Raw
In response to Comparing dates in 3.0  (Ellen Spertus <spertus@mills.edu>)
List pgsql-general
Hi Ellen,

Subtracting one timestamp from another returns an interval type, like
this:

stasis=# select 'now'::timestamp - '10 Sep 2000'::timestamp;
  ?column?
-------------
 75 12:06:57
(1 row)

But if you just want the days only, try this:

stasis=# select date_part('days', 'now'::timestamp - '10 Sep
2000'::timestamp);
 date_part
-----------
        75
(1 row)

Hope this helps.

Regards

Francis

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Ellen Spertus
> Sent: 17 November 2000 04:39
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] Comparing dates in 3.0
>
>
> After upgrading from 6.x to 7.x, the following query broke, I
> lost the
> ability to check how many days apart two DATEs are by subtracting
> them.  What is the correct way to determine the difference
> between two
> dates in 7.x?
>
> Thank you.
>
> Ellen Spertus
>
>


pgsql-general by date:

Previous
From: Robert Boyd
Date:
Subject: Re: [NOVICE] Skipping numbers in a sequence.
Next
From: hubert depesz lubaczewski
Date:
Subject: create snapshot?