Thread: Re: [NOVICE] to_days(now())

Re: [NOVICE] to_days(now())

From
"Joel Burton"
Date:
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)

Re: Re: [NOVICE] to_days(now())

From
Peter Eisentraut
Date:
Joel Burton writes:

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

Which is pretty odd considering the fact that there was no year 0.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/