Re: "order by" days of the week

From: Roland Roberts <roland(at)astrofoto(dot)org>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: "order by" days of the week
Date: 2002-09-29 00:30:06
Message-ID: m21y7dljsh.fsf@kuiper.rlent.pnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

>>>>> "D" == D A <lameije(at)yahoo(dot)com> writes:

D> 2)Is there a way to store days of the week that is better than simply
D> using varchar and performing a check. I read about the time data formats
D> and they all seem to be more applicable to absolute times rather than
D> simply a day of the week. I also thought about storing the days as a
D> number between 1 and 7 then converting for display (1=Monday,
D> 2=Tuesday...), but that didn't feel clean to me.

The was I've seen this done is to have an extra lookup table where
1=Monday does the translation between the key (the value 1) and the
human-readable version (the value "Monday"). I've not seen it for
this particular case (days of the week), but the idea is quite
general and works fine for this case.

roland
--
PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD RL Enterprises
roland(at)rlenter(dot)com 76-15 113th Street, Apt 3B
roland(at)astrofoto(dot)org Forest Hills, NY 11375

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message J Matt Clark 2002-09-29 17:29:32 virus in download of 7.2.2?
Previous Message Oliver Elphick 2002-09-28 20:24:04 Re: "order by" days of the week