Обсуждение: to_days(now())

Поиск
Список
Период
Сортировка

to_days(now())

От
Brian Aker
Дата:
Hi all.
I've been looking for a good reference for the built
in time functions and have yet to find any.
What I really need is something similar to MySQL's:
select to_days(now());

This returns the number of days since year one from
the current time in the database.
Thanks for any help in advance (please CC  me directly
since I don't subscribe to this mailing list).

    -Brian

--
_______________________________________________________
Brian Aker, brian@tangent.org
Slashdot Senior Developer
Seattle, Washington
http://tangent.org/~brian/
http://slashdot.org/
_______________________________________________________
You can't grep a dead tree.

Re: to_days(now())

От
"Joel Burton"
Дата:
On 28 Nov 2000, at 13:12, Brian Aker wrote:

> I've been looking for a good reference for the built
> in time functions and have yet to find any.

Try the functions reference in the postgresql manual--there's a lot of
information about Pgsql date/time functions there, but in your case, no
function is needed--overloaded operators will work fine.

> What I really need is something similar to MySQL's:
> select to_days(now());
>
> This returns the number of days since year one from
> the current time in the database.
> Thanks for any help in advance (please CC  me directly
> since I don't subscribe to this mailing list).

select yourdate - '0000-01-01'::date from yourtable;

seems to work just fine, and returns an integer.

Both PostgreSQL and MySQL say there have been  730485 between 1/1/0
and 1/1/2000. Something we all can agree on? :-)

Good luck w/your app,

--
Joel Burton, Director of Information Systems -*- jburton@scw.org
Support Center of Washington (www.scw.org)