'1 year' = '360 days' ????

From: "Ricardo Perez Lopez" <ricpelo(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: '1 year' = '360 days' ????
Date: 2004-10-22 11:37:19
Message-ID: BAY15-F25yabYTHrdus00003972@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello everyone:

I'm a PostgreSQL newbie, working now with dates, times, timestamps and
intervals.

I have three questions about the above:

FIRST:
--------

I have observed that, for PostgreSQL, one year is actually 360 days:

SELECT '1 year'::timestamp = '360 days'::timestamp;

?column?
-------------
t

Glubs! I believed that 1 year is 365 days, or 366 if leap. Is it normal?

SECOND:
-----------

When I want to check how many time is between two dates, I have two options
(which shows two different results):

SELECT '30-09-04'::timestamp - '30-09-03'::timestamp,
age('30-09-04'::timestamp, '30-09-03'::timestamp);

?column? | age
-------------------------------
@ 366 days | @ 1 year

The results are different. If we compare the two results:

SELECT ('30-09-04'::timestamp - '30-09-03'::timestamp) =
age('30-09-04'::timestamp, '30-09-03'::timestamp);

?column?
--------------
f

Obviously, it returns False, because I told in the first question, 1 year is
360 days for PostgreSQL.

The question is: is it normal? Which of the two methods is the correct? To
substract timestamps? Or to use the age function?

THIRD:
--------

As I told in the second question, when I do:

SELECT '30-09-04'::timestamp - '30-09-03'::timestamp;

the result is:

?column?
--------------
@ 366 days

The question is: is there any way to "normalize" the result, such that the
result was:

@ 1 year 1 day

?

I think it's better (and more correct) "@ 1 year 1 day" rather than "@ 366
days". Is there any way to achieve that?

Thanks to all.

Ricardo.

_________________________________________________________________
Horóscopo, tarot, numerología... Escucha lo que te dicen los astros.
http://astrocentro.msn.es/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Wells 2004-10-22 12:52:28 PostgreSQL-related job posting
Previous Message Philippe Lang 2004-10-22 10:59:19 FKs and deadlocks