Re: HOW-TO do incomplete dates: year, optional month, optional day?

From: will trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: HOW-TO do incomplete dates: year, optional month, optional day?
Date: 2003-01-23 20:20:43
Message-ID: 20030123202042.GA3251@mail.serensoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 23, 2003 at 11:48:27AM -0600, will trillich wrote:
> On Thu, Jan 23, 2003 at 11:34:27AM +0000, Richard Huxton wrote:
> > On Wednesday 22 Jan 2003 10:11 pm, will trillich wrote:
> > > is there a way, save lots of manual manipulation and
> > > hand-waving, to implement PARTIAL DATES?
>
> > The only other thing I can think of would be to store it all
> > as an INT4, so for the examples above you'd store
> >
> > 19910000
> > 19981100
> > 20010517
> >
> > So you're using the zeroes as n/a but still keeping the value as one column.
> > Add a check function valid_partial_date(..) and a display fn
> > show_partial_date(...)
>
> hey, that's a good idea! or maybe store the year in the first
> two bytes, the month in byte three, and the day in byte four.
> that'd be pretty simple... maybe i should define a new type?
>
> CREATE TYPE partial_date ...

i finally found the xtypes.html on postgresql.org/idocs and it
gives examples of C functions. is it a bad idea to use plpgsql
as the language for creating types?

if so, where do i find the #includes and !gcc command options to
pass so it won't gripe about not finding "main()"?

--
There are 10 kinds of people:
ones that get binary, and ones that don't.

will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Looking for a firewall? Do you think smoothwall sucks? You're
probably right... Try the folks at http://clarkconnect.org/ !

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Colls 2003-01-23 20:48:43 Last Committed Transaction
Previous Message Matthew Nuzum 2003-01-23 20:02:33 Re: I was spoiled by the MySQL timestamp field