Re: Oracle-Style Date Functions

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: David Rickard <David(dot)Rickard(at)GTScompanies(dot)com>, pgsql-novice(at)postgresql(dot)org
Cc: Judith Strawser <judiths(at)GTScompanies(dot)com>
Subject: Re: Oracle-Style Date Functions
Date: 2003-12-05 19:15:35
Message-ID: 200312051115.35047.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

David,

> Has anyone developed PostgreSQL versions of the Oracle date functions? I'm
> especially interested in ports of ADD_MONTHS and NEXT_DAY, or hints on
> replicating them in PostgreSQL.

Trivial:

CREATE FUNCTION add_months (timestamp, integer)
RETURNS timestamp AS '
SELECT $1 + (''1 month''::INTERVAL * $2);
' LANGUAGE SQL IMMUTABLE, STRICT;

CREATE FUNCTION NEXT_DAY (timestamp)
RETURNS timestamp AS '
SELCET $1 + ''1 day''::INTERVAL;
' LANGUAGE SQL IMMUTABLE, STRICT;

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message David Benoff 2003-12-05 19:49:32 PostgreSQL and ADO.net?
Previous Message Sai Hertz And Control Systems 2003-12-05 12:53:56 Re: Managing users