Re: How cast interval to minutes as number?
От | Andreas Kretschmer |
---|---|
Тема | Re: How cast interval to minutes as number? |
Дата | |
Msg-id | 20071125085321.GA20882@KanotixBox обсуждение исходный текст |
Ответ на | How cast interval to minutes as number? (Andreas <maps.on@gmx.net>) |
Ответы |
Re: How cast interval to minutes as number?
|
Список | pgsql-novice |
Andreas <maps.on@gmx.net> schrieb: > Hi, > > I have a column with timestamps --> some_ts . > I'd like to calculate the amount of time between this timestamp and NOW(). > > select some_ts - NOW() from some_table; > > This results in a column of type interval. > How would I get this interval converted into e.g. minutes. Okay, lets assume i want to know how old is my daughter, in minutes: test=# select EXTRACT (EPOCH FROM now() - '2007-07-28 09:15:00'::timestamp )::int/60; ?column? ---------- 172896 (1 row) You can exchange the fix timestamp with a column from a table, no problem. Hope that helps, Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
В списке pgsql-novice по дате отправления: