pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Campbell, Lance <lance@illinois.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: subtract two dates to get the number of days
Date: Tue, 13 Jul 2010 11:02:10 -0400
Message-ID: <29026.1279033330@sss.pgh.pa.us> (raw)
In-Reply-To: <B10E6810AC2A2F4EA7550D072CDE876004B2E65D@SAB-FENWICK.sab.uiuc.edu>
References: <B10E6810AC2A2F4EA7550D072CDE876004B2E65D@SAB-FENWICK.sab.uiuc.edu>

"Campbell, Lance" <lance@illinois.edu> writes:
> I want to subtract to dates to know the number of days different.
> Example:
> 01/02/2010 - 01/01/2010 = 1 day
> 08/01/2010 - 07/31/2010 = 1 day
> How do I do this? 

If they're dates, you just subtract.

regression=# select '08/01/2010'::date - '07/31/2010'::date;
 ?column? 
----------
        1
(1 row)


			regards, tom lane



view thread (8+ messages)  latest in thread

Message-ID: <29026.1279033330@sss.pgh.pa.us>
Permalink:  ../29026.1279033330@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29026.1279033330@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lance@illinois.edu
  Subject: Re: subtract two dates to get the number of days
  In-Reply-To: <29026.1279033330@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox