Re: subtract two dates to get the number of days

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: subtract two dates to get the number of days
Date: 2010-07-14 16:06:22
Message-ID: i1kn9t$9e5$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Lee Hachadoorian 2010-07-14 16:21:26 Re: Question on COUNT performance
Previous Message Reinoud van Leeuwen 2010-07-14 13:44:10 Re: Question on COUNT performance