Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C4C4C632B68 for ; Wed, 14 Jul 2010 09:37:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 74703-07 for ; Wed, 14 Jul 2010 12:37:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from vms173005pub.verizon.net (vms173005pub.verizon.net [206.46.173.5]) by mail.postgresql.org (Postfix) with ESMTP id 2649063291E for ; Wed, 14 Jul 2010 09:37:20 -0300 (ADT) Received: from trillian.localdomain ([unknown] [96.240.12.15]) by vms173005.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0L5J00IXSSDVIY70@vms173005.mailsrvcs.net> for pgsql-sql@postgresql.org; Wed, 14 Jul 2010 07:37:07 -0500 (CDT) Message-id: <4C3DAF72.6030606@verizon.net> Date: Wed, 14 Jul 2010 08:37:06 -0400 From: Jean-David Beyer Organization: Institute for Regimented Whimsey User-Agent: Thunderbird 2.0.0.24 (X11/20100318) MIME-version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: subtract two dates to get the number of days References: In-reply-to: X-Enigmail-Version: 0.96.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/63 X-Sequence-Number: 34376 -----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-----