Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dktxJ-0003qa-Aa for pgsql-sql@arkaria.postgresql.org; Thu, 24 Aug 2017 15:22:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dktxI-0003wc-IZ for pgsql-sql@arkaria.postgresql.org; Thu, 24 Aug 2017 15:22:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dktxI-0003wS-4B for pgsql-sql@postgresql.org; Thu, 24 Aug 2017 15:22:00 +0000 Received: from mail231.strasbourg.4js.com ([92.103.31.231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dktxF-0007ai-0J for pgsql-sql@postgresql.org; Thu, 24 Aug 2017 15:21:59 +0000 Received: from [10.0.40.29] (orion.strasbourg.4js.com [10.0.40.29]) (authenticated bits=0) by mail231.strasbourg.4js.com (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id v7OFLtGY010097 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Thu, 24 Aug 2017 17:21:55 +0200 To: "pgsql-sql@postgresql.org" From: Sebastien FLAESCH Subject: Determining the DATE format with libpq Organization: Four Js Development Tools Message-ID: <46935bcd-5754-9deb-fc63-8162bcdd4c46@4js.com> Date: Thu, 24 Aug 2017 17:21:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99.1 at mail231 X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail231.strasbourg.4js.com [10.10.0.1]); Thu, 24 Aug 2017 17:21:55 +0200 (CEST) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Hi all, The date format can be defined with SET DateStyle. When fetching result set values using the libpq C API, we get plain text from PQgetvalue(), representing a date in the current format. We need to extract date parts (year/month/day) to fill our own DATE type structure... Is there a way to know the current date format used in the SQL session? Ideally, we expect a libpq API. We cannot do a "SHOW DateStyle" each time we executing a SELECT! Other DB client C APIs provide a C structure to hold DATE values so it's easy to get year/month/day parts. Seb -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql