Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id BA96B1337B5C for ; Wed, 5 Jan 2011 22:33:37 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 41742-02 for ; Thu, 6 Jan 2011 02:33:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id 44E731337B49 for ; Wed, 5 Jan 2011 22:33:29 -0400 (AST) Received: by vws16 with SMTP id 16so6704867vws.19 for ; Wed, 05 Jan 2011 18:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:reply-to:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id; bh=Y0im93PhOTsPBjkdF3LFnsytx6tSk1292BwwiYXabLc=; b=JkF0Uv7IzSkqaolGU0Nv3E8kw5rUl2LU9aCzsPp0OCsNMFp/hyUpDemLZHhoxj890g OEBGI8npblu6NNkhPtFl8X/cdfAIExWWFchr+LtJgO87J/DNYlSKfFAyeGc7Gazteguh MtYE5utURP75+2/s62GnwYT93tADOwbeE5rdU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id; b=hpwIQDX46Cw7xtd2bOc6dNX8WZBvzHttE3vjO6JkyagA2XPgOFqbo65FZgm1NcQNCs tKEUeDdo7rKnnaR+35Y+QpaPLjvbKt0NoMULWu7uqSzBrXsDON3TdmRzpwKilbpATHLt I9bnx5qqpRA+jTZyEL7A1CDlkZYLGY//erkt0= Received: by 10.220.186.3 with SMTP id cq3mr3117026vcb.262.1294281208214; Wed, 05 Jan 2011 18:33:28 -0800 (PST) Received: from tucker.local (c-24-17-164-54.hsd1.wa.comcast.net [24.17.164.54]) by mx.google.com with ESMTPS id o6sm5172291vcr.3.2011.01.05.18.33.27 (version=SSLv3 cipher=RC4-MD5); Wed, 05 Jan 2011 18:33:27 -0800 (PST) From: Adrian Klaver Reply-To: adrian.klaver@gmail.com To: pgsql-sql@postgresql.org Subject: Re: explicit casts Date: Wed, 5 Jan 2011 18:33:27 -0800 User-Agent: KMail/1.9.10 Cc: Iuri Sampaio References: <4D250BC2.2060207@gmail.com> <4D251956.5050309@gmail.com> In-Reply-To: <4D251956.5050309@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201101051833.28052.adrian.klaver@gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.588 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201101/11 X-Sequence-Number: 34958 On Wednesday 05 January 2011 5:22:30 pm Iuri Sampaio wrote: > So far, > I could write the following query > > select to_char(trunc(to_date('2010-01-02', 'yyyy-mm-dd'), 'Month'), > 'fmMonth') as month, > to_char(trunc(to_date('2010-01-02', 'yyyy-mm-dd'), 'Month'), 'YYYY') as > year, > to_char(trunc(to_date('2010-01-02', 'yyyy-mm-dd'), 'Month'), 'J') as > first_julian_date_of_month, > to_char(last_day('2010-01-02')::date, 'DD') as num_days_in_month, > to_char(trunc(to_date('2010-01-02', 'yyyy-mm-dd'), 'Month'), 'D') as > first_day_of_month, > to_char(last_day('2010-01-02')::date, 'DD') as last_day, > trunc(add_months(to_date('2010-01-02', 'yyyy-mm-dd'), 1),'Day') as > next_month, > trunc(add_months(to_date('2010-01-02', 'yyyy-mm-dd'), -1),'Day') as > prev_month, > trunc(to_date('2010-01-02', 'yyyy-mm-dd'), 'year') as beginning_of_year, > to_char(last_day(add_months('2010-01-02', -1))::date, 'DD') as > days_in_last_month, > to_char(add_months(to_date('2010-01-02', 'yyyy-mm-dd'), 1), 'fmMonth') > as next_month_name, > to_char(add_months(to_date('2010-01-02', 'yyyy-mm-dd'), -1), 'fmMonth') > as prev_month_name > from dual > > > But i still miss some lines in order to properly explicit casts in the > query > > cheers, > iuri My guess is you upgraded from a version prior to 8.3. In 8.3 many of the implied casts where removed, so you probably have to go over your code and make the corrections. Go here for more detail: http://www.postgresql.org/docs/8.4/interactive/release-8-3.html Section E.21.2.1. General A temporary solution can be found here: http://petereisentraut.blogspot.com/2008/03/readding-implicit-casts-in-postgresql.html An important tip from the blog- "The gist was, only restore the casts you need, not all of them." -- Adrian Klaver adrian.klaver@gmail.com