Re: [NOVICE] to_days(now()) - Mailing list pgsql-general

From Joel Burton
Subject Re: [NOVICE] to_days(now())
Date
Msg-id 3A2BB8D9.12561.12339D5@localhost
Whole thread Raw
Responses Re: Re: [NOVICE] to_days(now())
List pgsql-general
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)

pgsql-general by date:

Previous
From: "Alistair Hopkins"
Date:
Subject: RE: Built in Functions use with recordsets
Next
From: "JB"
Date:
Subject: Re: [PHP] RE: [SQL] a script that queries database periodically