Skip site navigation (1) Skip section navigation (2)

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 (view raw or whole 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.

		       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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group