age('now',date::datetime)

Поиск
Список
Период
Сортировка
От Bob Dusek
Тема age('now',date::datetime)
Дата
Msg-id 36419394.5AC4FD2C@palaver.net
обсуждение исходный текст
Ответы RE: [GENERAL] age('now',date::datetime)  (Mario Filipe <mjnf@uevora.pt>)
Список pgsql-general
Hello again,

I am using the age() function to determine the average shelf-life of
inventory items that are being stored in my database.  And, I think the
function is definitely worth having around.  It is saving me a lot of
time.  However (there's always a catch), I think it would be a hundred
times more useful to me if I could, using some sort of Postgres function
or conversion operator, take the output of the age function, which is
returned as type 'timespan' and condense that into just 'days' or
'months'.

In other words, when I do this:

    database => select age('now', '09-01-1998'::datetime);

Instead of it telling me this:

age
---------------------------------------
@ 2 mons 4 days 6 hours 40 mins 47 secs

I would like to be able to make it tell me:

age
---------
66.3 days

or something to that effect.

Is there a way I can do this?  At first, I tried the date_part function,
but (for obvious reasons) it didn't do what I thought it was doing.

Please let me know,

Bob

В списке pgsql-general по дате отправления:

Предыдущее
От: Joe Fisher
Дата:
Сообщение: Help with PostgreSQL...
Следующее
От: Bob Dusek
Дата:
Сообщение: Re: [GENERAL] casting float8 type