Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id AE227632E8E for ; Wed, 14 Jul 2010 13:06:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 99864-01 for ; Wed, 14 Jul 2010 16:06:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 91B796327AE for ; Wed, 14 Jul 2010 13:06:34 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OZ4Te-00007i-BD for pgsql-sql@postgresql.org; Wed, 14 Jul 2010 18:06:30 +0200 Received: from ppp-188-174-2-78.dynamic.mnet-online.de ([188.174.2.78]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 Jul 2010 18:06:30 +0200 Received: from spam_eater by ppp-188-174-2-78.dynamic.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 Jul 2010 18:06:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Kellerer Subject: Re: subtract two dates to get the number of days Date: Wed, 14 Jul 2010 18:06:22 +0200 Lines: 19 Message-ID: References: <4C3DAF72.6030606@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ppp-188-174-2-78.dynamic.mnet-online.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 In-Reply-To: <4C3DAF72.6030606@verizon.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-5 required=5 tests=BAYES_40=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/66 X-Sequence-Number: 34379 Jean-David Beyer wrote on 14.07.2010 14:37: > My dates are of the form yyyy-mm-dd and such. Storing a date as a string is never a good idea. > And I want to do things like adding or subtracting days, months, or years to it or from it. >Also the logical comparisons. Which is all a piece of cake when you use the proper datatype > 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, To be honest: I expect the programming language to support those things. > 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. I would expect doing "date maths" with strings is wasting more CPU than using a native date datatype. Just my €0.02 Thomas