Re: Obtaining the Julian Day from a date

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

On Thu, Sep 09, 2004 at 16:32:18 -0500,
"Karl O. Pinc" <kop(at)meme(dot)com> wrote:
>
> 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.)

If you keep your data in a date field you can get the Julian day
by subtracting the appropiate date. You can then do mod on this
difference.

You could also do the subtraction before storing the data if you want
to keep it internally as Julian days.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2004-09-11 01:56:20 Re: how to constrain a query to return 1 or 0 rows (or >1 or 0 rows)
Previous Message Nick 2004-09-11 00:32:54 Auto increment/sequence on multiple columns?