X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D8208329E73 for ; Wed, 20 Oct 2004 00:01:14 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57476-03 for ; Tue, 19 Oct 2004 23:01:03 +0000 (GMT) Received: from screen.dri.edu (screen.dri.edu [134.197.100.251]) by svr1.postgresql.org (Postfix) with ESMTP id 5AF46329D9E for ; Wed, 20 Oct 2004 00:01:02 +0100 (BST) Received: (from fw_mx@localhost) by screen.dri.edu (8.9.1b+Sun/8.9.1) id QAA04474; Tue, 19 Oct 2004 16:01:00 -0700 (PDT) Received: from derringer.dri.edu( 10.10.9.111) by screen.dri.edu via smap (V2.1.dri) id xma004469; Tue, 19 Oct 04 16:00:51 -0700 Received: from dri.edu (ppp18.dri.edu [10.10.8.218]) by derringer.dri.edu (8.9.3+Sun/8.9.1) with ESMTP id QAA08763; Tue, 19 Oct 2004 16:00:49 -0700 (PDT) Message-ID: <41759E68.1050405@dri.edu> Date: Tue, 19 Oct 2004 16:08:24 -0700 From: lorid User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7a) Gecko/20040219 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Thomas F.O'Connell" Cc: pgsql-sql@postgresql.org Subject: Re: help with to_date and to_char References: <416C74CC.6030309@dri.edu> <9E1E7300-2215-11D9-A5E5-000D93AE0944@sitening.com> In-Reply-To: <9E1E7300-2215-11D9-A5E5-000D93AE0944@sitening.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/133 X-Sequence-Number: 19236 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