Thread: interval in days

interval in days

From
Tomka Gergely
Date:
date_part('epoch', date_trunc('day', TIMESTAMP 'now') -
date_trunc('day', hiba.datum)) / (60*60*24)

I hope there are a simple solution for this - i want to know the age of
hiba.datum, in days. If one year old, then i need 365.

--
Tomka Gergely
"S most - vajon barbárok nélkül mi lesz velünk?
Ők mégiscsak megoldás voltak valahogy..."


Re: interval in days

From
Tom Lane
Date:
Tomka Gergely <tomka@zeus.gau.hu> writes:
> I hope there are a simple solution for this - i want to know the age of
> hiba.datum, in days. If one year old, then i need 365.

Cast both to type "date" and subtract.

regression=# select current_date - ('1999-08-25'::date);
 ?column?
----------
     1461
(1 row)


            regards, tom lane