pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lorid <lorid@dri.edu>
To: Thomas F.O'Connell <tfo@sitening.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: help with to_date and to_char
Date: Tue, 19 Oct 2004 16:08:24 -0700
Message-ID: <41759E68.1050405@dri.edu> (raw)
In-Reply-To: <9E1E7300-2215-11D9-A5E5-000D93AE0944@sitening.com>
References: <416C74CC.6030309@dri.edu>
	<9E1E7300-2215-11D9-A5E5-000D93AE0944@sitening.com>

Thanks Thomas it worked great ,even when I put in the var - when_month
:)
Lori

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' );
>
> -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 12, 2004, at 7:20 PM, Lori wrote:
>
>> Im trying to do something very simple
>> I have a field called when_month (integer )
>> so I want to get the month name for the integer
>>
>> this comes close to what I want
>> update mytable set myfield=to_char(current_timestamp,'MON');
>>
>> the result is myfield is set to OCT
>> which is close to what I want but when I try to use a variable
>> update mytable set myfield=to_char(when_month,'MON');
>> or a char with value of '05' or '5'
>> update mytable set myfield=to_char('05','MON');
>> get error:
>> update mytable set myfield=to_date(when_month,'MON');
>> update mytable set myfield=to_char('05','MON');
>> as well as
>> update mytable set full_month= to_date('01/'05'/2004','DDMONYYYY');
>> all get errors
>>
>> Please can anyone help?
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 8: explain analyze is your friend
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend





view thread (6+ messages)  latest in thread

Message-ID: <41759E68.1050405@dri.edu>
Permalink:  ../41759E68.1050405@dri.edu/
Also on:    postgresql.org/message-id/41759E68.1050405@dri.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lorid@dri.edu, tfo@sitening.com
  Subject: Re: help with to_date and to_char
  In-Reply-To: <41759E68.1050405@dri.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox