From: | Jean-David Beyer <jeandavid8(at)verizon(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: subtract two dates to get the number of days |
Date: | 2010-07-14 12:37:06 |
Message-ID: | 4C3DAF72.6030606@verizon.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
-----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-----
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua Tolley | 2010-07-14 13:30:39 | Re: Question on COUNT performance |
Previous Message | Reinoud van Leeuwen | 2010-07-14 12:30:29 | Re: Question on COUNT performance |