Re: "order by" days of the week - Mailing list pgsql-novice

From Roland Roberts
Subject Re: "order by" days of the week
Date
Msg-id m21y7dljsh.fsf@kuiper.rlent.pnet
Whole thread Raw
In response to "order by" days of the week  ("D. A." <lameije@yahoo.com>)
List pgsql-novice
>>>>> "D" == D A <lameije@yahoo.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@rlenter.com                     76-15 113th Street, Apt 3B
roland@astrofoto.org                       Forest Hills, NY 11375

pgsql-novice by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: "order by" days of the week
Next
From: J Matt Clark
Date:
Subject: virus in download of 7.2.2?