Re: help with to_date and to_char - Mailing list pgsql-sql

From Thomas F.O'Connell
Subject Re: help with to_date and to_char
Date
Msg-id 4489EDEA-2248-11D9-A5E5-000D93AE0944@sitening.com
Whole thread Raw
In response to Re: help with to_date and to_char  (Edmund Bacon <ebacon@onesystem.com>)
List pgsql-sql
Yup, even better. For some reason I gave up trying to_date( '02', 'MON' 
), which clearly wasn't working.

Thanks for the improvement!

-tfo

--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005

On Oct 19, 2004, at 6:00 PM, Edmund Bacon wrote:

> Thomas F.O'Connell wrote:
>> There might be a better way, but this should do what you want. And I 
>> think that you can safely replace '05' with when_month.
>> select to_char( to_date( '05' || '/' || to_char( current_date, 
>> 'DD/YYYY' ), 'MM/DD/YYYY' ), 'MON' );
>
> Perhaps
>  select to_char(to_date('02', 'MM'), 'MON');
>
> is better.  When current_date is, say Aug 31 then
>
> select to_char( to_date('05' || '/' || to_char(current_date, 
> 'DD/YYYY'),
>                 'MM/DD/YYYY' ), 'MON' );
>
> returns 'MAR', which is probably not what you want.
>
> This works with 7.3.2, 7.4.5 and 8.0beta2.



pgsql-sql by date:

Previous
From: Postgres User
Date:
Subject: Which type of functions are best?
Next
From: "Muhyiddin A.M Hayat"
Date:
Subject: Cross tabulations