pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-David Beyer <jeandavid8@verizon.net>
To: pgsql-sql@postgresql.org
Subject: Re: subtract two dates to get the number of days
Date: Wed, 14 Jul 2010 08:37:06 -0400
Message-ID: <4C3DAF72.6030606@verizon.net> (raw)
In-Reply-To: <B10E6810AC2A2F4EA7550D072CDE876004B2E65D@SAB-FENWICK.sab.uiuc.edu>
References: <B10E6810AC2A2F4EA7550D072CDE876004B2E65D@SAB-FENWICK.sab.uiuc.edu>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Campbell, Lance wrote:
> 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?
> 
Others have posted SQL answers to this. Which is fine if you need to do
it in SQL.

My dates are of the form yyyy-mm-dd and such. And I want to do things
like adding or subtracting days, months, or years to it or from it. Also
the logical comparisons.

Years ago, I made a C++ data type that allowed a date datatype where I
could add, subtract, and so on.

I use it in programs that do not necessarily use a database, but also in
programs that do when the computations are the big part of the cpu load,
as contrasted to just "gentle" massaging of existing data.


- --
  .~.  Jean-David Beyer          Registered Linux User 85642.
  /V\  PGP-Key: 9A2FC99A         Registered Machine   241939.
 /( )\ Shrewsbury, New Jersey    http://counter.li.org
 ^^-^^ 08:20:01 up 6 days, 17:06, 4 users, load average: 4.77, 4.78, 4.87
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with CentOS - http://enigmail.mozdev.org/

iD8DBQFMPa9yPtu2XpovyZoRAnuDAJ9U9yghDl8NkGNv1pWSxIwXsDBTXwCgiv1L
INK1dzbUQnWBjhXXrQu6ZsM=
=lyR9
-----END PGP SIGNATURE-----



view thread (8+ messages)  latest in thread

Message-ID: <4C3DAF72.6030606@verizon.net>
Permalink:  ../4C3DAF72.6030606@verizon.net/
Also on:    postgresql.org/message-id/4C3DAF72.6030606@verizon.net

 · 

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: jeandavid8@verizon.net
  Subject: Re: subtract two dates to get the number of days
  In-Reply-To: <4C3DAF72.6030606@verizon.net>

* 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