Re: [NOVICE] to_days(now())

From: "Joel Burton" <jburton(at)scw(dot)org>
To: brian(at)tangent(dot)org
Cc: pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] to_days(now())
Date: 2000-12-04 20:31:37
Message-ID: 3A2BB8D9.12561.12339D5@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

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(at)scw(dot)org
Support Center of Washington (www.scw.org)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joel Bernstein 2000-12-04 20:34:46 Docs for beta 7.1
Previous Message Joel Burton 2000-12-04 20:27:34 Re: [SQL] Access Permissions/Security

Browse pgsql-novice by date

  From Date Subject
Next Message Joel Burton 2000-12-04 22:03:21 Re: Re: [NOVICE] Password protection?
Previous Message Joel Burton 2000-12-04 18:49:49 Re: [NOVICE] Password protection?