X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E8E13D1B8B7 for ; Fri, 5 Sep 2003 14:30:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 42145-07 for ; Fri, 5 Sep 2003 11:29:57 -0300 (ADT) Received: from web20808.mail.yahoo.com (web20808.mail.yahoo.com [216.136.226.197]) by svr1.postgresql.org (Postfix) with SMTP id 75F59D1B89D for ; Fri, 5 Sep 2003 11:29:52 -0300 (ADT) Message-ID: <20030905142956.89456.qmail@web20808.mail.yahoo.com> Received: from [208.13.35.65] by web20808.mail.yahoo.com via HTTP; Fri, 05 Sep 2003 07:29:56 PDT Date: Fri, 5 Sep 2003 07:29:56 -0700 (PDT) From: Jeff Eckermann Subject: Re: Porting from Oracl to Postgres To: Jomon Skariah Cc: pgsql-sql@postgresql.org In-Reply-To: <1062770250.66151.9.camel@jester> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/32 X-Sequence-Number: 15010 --- Rod Taylor wrote: > On Fri, 2003-09-05 at 00:24, Jomon Skariah wrote: > > > > Hi, > > > > Thanks for your replys. > > > > We are facing another problem now. > > > > we need to find an alternative for Oracle's > ADD_MONTHS in PostGres.. > > Guessing based on the name that it adds a quantity > of months to a > timestamp. How about an SQL Interval? > > now() + interval '15 months' > > List of functions: > http://www.postgresql.org/docs/7.3/interactive/functions.html For compatibility in your application, you could do something like: CREATE FUNCTION add_months(date, integer) RETURNS date AS ' SELECT ($1 + ( $2::text || '' months'')::interval)::date; ' LANGUAGE 'sql'; I second the recommendation to spend some time looking over the available functions in PostgreSQL. __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com