Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 3E364133798E for ; Wed, 5 Jan 2011 20:24:44 -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 72760-03 for ; Thu, 6 Jan 2011 00:24:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f174.google.com (mail-gx0-f174.google.com [209.85.161.174]) by mail.postgresql.org (Postfix) with ESMTP id D2100133616B for ; Wed, 5 Jan 2011 20:24:36 -0400 (AST) Received: by gxk9 with SMTP id 9so3565789gxk.19 for ; Wed, 05 Jan 2011 16:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=sLAE1QgMqpSjJ4Hd6YAKkK32HeOWCZF0SWWOzLOEOk8=; b=aUKKCxmZkqvx/mFaA/QFT97rrRvrCEQkFdv6RhJT0RCLaWTIahliFCKeM/OyBrNaIL YduiAP6B8Ee7lrrHZthK7GjXDiLPcX3Tw6vwjqtlPdm+dOG5KSacMNjcrz/7yMQu8Y8k 8o9FALo1AJIcyg2ZtzHwcsXjnoq1N8pyt/w1U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=d7kEgCUzMiIQm1Y5lCphAChZrJ8mQW4HWrkngHFPI26cr05+Yzg0DnsvgyOB9WDSrU vjgIdXYMF8YlGjM1/MGaVD5rzq/VwlbqbP2JxpBNyjrHsXNtl+b+HJMvFF5ou/MDw6J6 zR/fb5/tASy86ibIZSURGaBQajz5k3i3DKGIs= Received: by 10.91.214.14 with SMTP id r14mr1370236agq.46.1294273476865; Wed, 05 Jan 2011 16:24:36 -0800 (PST) Received: from [192.168.1.100] ([201.87.45.222]) by mx.google.com with ESMTPS id w4sm23817772anw.16.2011.01.05.16.24.36 (version=SSLv3 cipher=RC4-MD5); Wed, 05 Jan 2011 16:24:36 -0800 (PST) Message-ID: <4D250BC2.2060207@gmail.com> Date: Wed, 05 Jan 2011 22:24:34 -0200 From: Iuri Sampaio User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: explicit casts Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/8 X-Sequence-Number: 34955 Hi there, I installed postgresql 8.4 on my box and now i have troubles with the following query regarding explicit casts. select to_char(trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month'), 'fmMonth') as month, to_char(trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month'), 'YYYY') as year, to_char(trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month'), 'J') as first_julian_date_of_month, to_char(last_day(to_date(:the_date, 'yyyy-mm-dd')), 'DD') as num_days_in_month, to_char(trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month'), 'D') as first_day_of_month, to_char(last_day(to_date(:the_date, 'yyyy-mm-dd')), 'DD') as last_day, trunc(add_months(to_date(:the_date, 'yyyy-mm-dd'), 1),'Day') as next_month, trunc(add_months(to_date(:the_date, 'yyyy-mm-dd'), -1),'Day') as prev_month, trunc(to_date(:the_date, 'yyyy-mm-dd'), 'year') as beginning_of_year, to_char(last_day(add_months(to_date(:the_date, 'yyyy-mm-dd'), -1)), 'DD') as days_in_last_month, to_char(add_months(to_date(:the_date, 'yyyy-mm-dd'), 1), 'fmMonth') as next_month_name, to_char(add_months(to_date(:the_date, 'yyyy-mm-dd'), -1), 'fmMonth') as prev_month_name from dual the value assigned to the variable :the_date is '2010-01-05' The error is Error: Ns_PgExec: result status: 7 message: ERROR: function to_date(timestamp with time zone, unknown) does not exist LINE 1: select to_date(date_trunc('month',add_months( $1 ,1)),'YYYY-... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. QUERY: select to_date(date_trunc('month',add_months( $1 ,1)),'YYYY-MM-DD') - 1 CONTEXT: PL/pgSQL function "last_day" line 6 at SQL statement how would i apply the following solution date_trunc('month', p_date_in + interval '1 month')::date - 1 to fix the query above? cheers, iuri