Re: Obtaining the Julian Day from a date

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: "Karl O(dot) Pinc" <kop(at)meme(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Obtaining the Julian Day from a date
Date: 2004-09-09 21:32:18
Message-ID: 20040909163218.K31452@mofo.meme.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 2004.09.09 14:11 Bruno Wolff III wrote:
> On Thu, Sep 09, 2004 at 12:35:14 -0500,
> "Karl O. Pinc" <kop(at)meme(dot)com> wrote:
> > Hi,
> >
> > What's the best way to obtain the Julian day from a postgresql
> > date?
> >
> > PostgreSQL 7.3.4 on i386-redhat-linux-gnu, compiled by GCC
> > i386-redhat-linux-gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
> >
> > I'm doing some date arithmetic with 1 day intervals and want
> > to, for example, round to the even Julian day.
>
> You might be interested to know that there are operators that combine
> date and integer types that might be usable directly instead of
> converting to Julian days.

Thanks. (It's not documented for 7.3 but works. It is documented
for 7.4.)

Unfortunately modulo (%) does not operate on dates so I still need

to convert to Julian day. :-( I need to know where I am within a
regular repeating interval. Mostly, in my case, modulo 2.
(We arbitrarly decided to begin our interval on Julian Day 0.)

Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Aaron Birkland 2004-09-09 21:42:20 Re: Memory exhausted (leak?)
Previous Message Jeff Amiel 2004-09-09 21:30:17 Re: How to determine a database is intact?