Re: dow question

From: Keith Worthington <KeithW(at)NarrowPathInc(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: Michael Glaesemann <grzm(at)myrealbox(dot)com>
Subject: Re: dow question
Date: 2005-12-08 03:33:06
Message-ID: 4397A972.8060007@NarrowPathInc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Michael Glaesemann wrote:
>
> On Dec 8, 2005, at 11:03 , Keith Worthington wrote:
>
>> Is there a better way to do this? The CASE seems inefficient and
>> wordy but perhaps not.
>>
>> I was hoping for
>>
>> day_name(tbl_detail.ship_by_date) || tbl_detail.ship_by_date::text AS
>> sort_by_string
>>
>> but AFAIK day_name(date) or something like it is merely my fantasy. ;-)
>
>
> Will to_char() do what you want? Something like
>
> test=# select to_char(current_date, 'Day YYYY-MM-DD');
> to_char
> ----------------------
> Thursday 2005-12-08
> (1 row)
>
> http://www.postgresql.org/docs/current/interactive/functions-
> formatting.html
>
> Michael Glaesemann
> grzm myrealbox com

Michael,

That will do nicely. I didn't realize until now after your tip and
reading the to_char documentation how much I could do with to_char.

to_char(tbl_detail.ship_by_date, 'FMDay, YYYY/MM/DD') AS ship_by_string,

is exactly what the doctor ordered. Thanks for the tip.

--
Kind Regards,
Keith

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-12-08 04:11:19 Re: Error from trigger
Previous Message Michael Glaesemann 2005-12-08 03:17:22 Re: dow question