Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f51GLIE60362 for ; Fri, 1 Jun 2001 12:21:18 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 65757; Fri, 01 Jun 2001 09:21:17 -0700 From: "Josh Berkus" Subject: Re: Date manipulation To: Mark , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Fri, 01 Jun 2001 09:21:17 -0700 Message-ID: In-Reply-To: <200105311714.f4VHEbW24511@mail.ldssingles.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/4 X-Sequence-Number: 3207 Mark, > How does one perform date manipulation within SQL? For example, SQL > Server has a dateadd() function that takes a date part, scalar, and > the > date to manipulate. As I have remarked before, such functions as DATEADD are unnecessary in PostgreSQL because PostgreSQL has a proper implementation of Date data types, unlike MS SQL Server. Thus, to add to a date: new_date := old_date + INTERVAL('1 week'); Or to subtract: break_time := restart_time - stop_time; It's improtant to remeber that the differnence of two dates or times is an interval, and while you can add an interval to a date you cannot add two dates. Additionally, if you browse to Roberto Mello's PG/plSQL function library (see link for the PostgreSQL.org web site) you will find an extension to the OVERLAPS function that I find quite useful (I should, I wrote it!). -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco