Lists: | pgsql-sql |
---|
From: | Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | age() vs. timestamp substraction |
Date: | 2006-10-05 18:27:46 |
Message-ID: | cbcf271add3140fe7cff8d45f31af585@bugs.unl.edu.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
I just found this problem with the age() function, which AFAIK should give the same resulte as a subtraction of the argument from now(), but it doesn't.
prueba=> SELECT (now() - tc.last_cron),age(tc.last_cron),tc.intervalo FROM tareas_cron tc ;
?column? | age | intervalo
-------------------------------------+-------------------------------+-----------
@ 1 day 15 hours 13 mins 12.06 secs | @ 23 hours 59 mins 58.47 secs | @ 1 day
@ 15 hours 13 mins 12.06 secs | @ 1.52 secs ago | @ 30 mins
@ 15 hours 13 mins 12.08 secs | @ 1.50 secs ago | @ 10 mins
prueba=> SELECT version();
version
----------------------------------------------------------------------------------------
PostgreSQL 8.1.3 on i486-pc-linux-gnu, compiled by GCC cc (GCC) 4.0.3 (Debian 4.0.3-1)
Any ideas on why?
I starting to change my queries so they don't have the age() function anymore.
--
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: age() vs. timestamp substraction |
Date: | 2006-10-05 18:37:24 |
Message-ID: | 29752.1160073444@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> writes:
> I just found this problem with the age() function, which AFAIK should
> give the same resulte as a subtraction of the argument from now(),
Where did you get that idea? age's reference point is current_date (ie,
midnight) not now(). There are also some differences in the calculation
compared to a plain timestamp subtraction.
regards, tom lane
From: | Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: age() vs. timestamp substraction |
Date: | 2006-10-05 18:43:39 |
Message-ID: | c82791b724c34d828f27af409356eef7@bugs.unl.edu.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
On Thu, 05 Oct 2006 14:37:24 -0400, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> writes:
>> I just found this problem with the age() function, which AFAIK should
>> give the same resulte as a subtraction of the argument from now(),
>
> Where did you get that idea? age's reference point is current_date (ie,
> midnight) not now(). There are also some differences in the calculation
> compared to a plain timestamp subtraction.
Ignore anything I said. Just realized it said current_date. :-(
Sorry.
--
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------
From: | Jean-Paul Argudo <jean-paul(at)argudo(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
Subject: | Re: age() vs. timestamp substraction |
Date: | 2006-10-06 09:35:30 |
Message-ID: | 45262362.4030101@argudo.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Hi all,
> Where did you get that idea? age's reference point is current_date (ie,
> midnight) not now(). There are also some differences in the calculation
> compared to a plain timestamp subtraction.
I'm jumping on this thread to point out a little strange thing to me.
CURRENT_DATE, converted (stupidly) as a string *with* hour is "current
date at mid-day":
test=# select to_char(current_date,'YYYY-MM-DD HH:MI:SS');
to_char
---------------------
2006-10-06 12:00:00
(1 ligne)
It was a day when I had to debug a strange behaviour in a customer's
(bad) code :-)
Cheers,
--
Jean-Paul Argudo
www.PostgreSQLFr.org
www.dalibo.com
From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Jean-Paul Argudo <jean-paul(at)argudo(dot)org> |
Cc: | pgsql-sql(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
Subject: | Re: age() vs. timestamp substraction |
Date: | 2006-10-06 13:56:51 |
Message-ID: | 20061006065548.A16785@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
On Fri, 6 Oct 2006, Jean-Paul Argudo wrote:
> Hi all,
>
> > Where did you get that idea? age's reference point is current_date (ie,
> > midnight) not now(). There are also some differences in the calculation
> > compared to a plain timestamp subtraction.
>
> I'm jumping on this thread to point out a little strange thing to me.
> CURRENT_DATE, converted (stupidly) as a string *with* hour is "current
> date at mid-day":
>
>
> test=# select to_char(current_date,'YYYY-MM-DD HH:MI:SS');
> to_char
> ---------------------
> 2006-10-06 12:00:00
> (1 ligne)
>
> It was a day when I had to debug a strange behaviour in a customer's
> (bad) code :-)
That's both midnight and mid-day. It's asking for 12 hour time and no
AM/PM marker.