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

Поиск
Список
Период
Сортировка
От will trillich
Тема Re: HOW-TO do incomplete dates: year, optional month, optional day?
Дата
Msg-id 20030123174827.GA2336@mail.serensoft.com
обсуждение исходный текст
Ответ на Re: HOW-TO do incomplete dates: year, optional month, optional day?  (Richard Huxton <dev@archonet.com>)
Ответы Re: HOW-TO do incomplete dates: year, optional month, optional day?  (will trillich <will@serensoft.com>)
Список pgsql-general
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?
all of these three, below, would go into the same field in a
table (different records, of course :)

> >     "doug has worked at pinnacle since 1991".
> > not 1-jan-1991, not 31-dec-1991, but just plain-ol' 1991.
> >
> >     "beulah started here back in november of 1998."
> > not 1-november, not 30-november. just november, of 1999.
> >
> >     "my first day at acme corp was the 17th of may, 2001."
> > here, in that same field, we need year, month AND day.

> 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 ...

if so, i'm a bit in the dark as to what kind of functions i need
to create -- the docs for "create type" mention needing
functions for input and output, and apparently they need to
return "opaque"? in which case, how do they return values?  and
what are the arguments passed? i need an example to go by...

anybody got some examples of "input/output" functions for
creating types?

> PS - I'd use the new CREATE DOMAIN feature of 7.3 to name the type ready for
> checks on domains in a later release - when that's done it'll be much
> cleaner.

hmm. i'm still on 7.2.1 as yet (debian "we-dont-upgrade-until-its-
calcified-thoroughly" stable). sounds quite intriguing...

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

will@serensoft.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/ !

В списке pgsql-general по дате отправления:

Предыдущее
От: Renê Salomão
Дата:
Сообщение: Pg 7.3.1 & DBD::Pg 1.21
Следующее
От: dev@archonet.com
Дата:
Сообщение: Re: I was spoiled by the MySQL timestamp field