X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D4A24D1C7F7 for ; Wed, 23 Jul 2003 21:46:49 +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 64678-10 for ; Wed, 23 Jul 2003 18:46:09 -0300 (ADT) Received: from smtp.electroniccity.org (smtp.electroniccity.org [207.219.15.18]) by svr1.postgresql.org (Postfix) with ESMTP id 1DB6DD1C7F2 for ; Wed, 23 Jul 2003 18:46:48 -0300 (ADT) Received: from [172.16.2.153] (d2-153.electroniccity.org [172.16.2.153]) by smtp.electroniccity.org (Postfix) with ESMTP id 09FF1DF222 for ; Wed, 23 Jul 2003 17:42:42 -0500 (EST) User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 Date: Wed, 23 Jul 2003 17:49:54 -0400 Subject: Getting the year from a date column From: Lynna Landstreet To: Message-ID: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=USER_AGENT_MACOE X-Spam-Level: X-Archive-Number: 200307/43 X-Sequence-Number: 2155 I'm having a bit of trouble with one part of the PHP front end of the art gallery database I'm working on - specifically, extracting the year from the start date of an exhibition. I'm trying to print a list of exhibitions on the artist info pages, with the name, gallery space and year for each one, and everything's working except the year part. Here's what I have. First, near the beginning of the PHP portion of the page: $exh_query = "SELECT exhibition_name, start_date FROM exhibitions WHERE exhibition_id = '$exhibition_id'"; $exhibition_info = pg_exec($db, $exh_query); Then further down, where I want the year to appear in the exhibition list: $date = getdate (pg_result($exhibition_info, 0, 'start_date')); $year = $date['year']; echo $year; (The 0 for row is because the way the code is structured, $exhibition_info only contains one row.) But I'm not sure if getdate() is the right function to be using. It was the only function I could find in the PHP manual that was capable of breaking out the individual components of a date (day, month, year, etc.), but it seems to be ignoring the actual date in the query results and returning '1969' for everything. Any idea what I'm doing wrong? Is there a different function I should be using instead for this? BTW, I'm using PHP 4.1 (and PostgreSQL 7.2), thus the old-style pg function names (pg_result(), etc.). Thanks, Lynna -- Resource Centre Database Coordinator Gallery 44 www.gallery44.org