ECPG date output depends on database datestyle

From: Mark Smith <marksmith(dot)smith175(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: ECPG date output depends on database datestyle
Date: 2011-01-18 18:17:46
Message-ID: AANLkTi=BKqEc7=vKB+AqRD13-Lye4qwUbAt=CWL=Z4yT@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all,

I am using ECPG with PostgreSQL 9.0.2. I have datestyle set in the
postgresql.conf to be 'SQL, DMY' and I get unexpected (to me :) ) results
selecting dates from the database into a variable of type 'date'.

For example, the date 05/08/2010 selected into a date variable is output as
3780 which corresponds to 08/05/2010.

The same program which returns the date as 3780 correctly returns '8' from
'select extract(month from mydatefield) ...' and all other queries show that
the database understands the date to be 05/08/2010 (5th August 2010).

If I change datestyle to 'SQL, MDY' and restart the engine, the date is
output correctly as 3869 and all other operations are consistent.

If the date has no possible ambiguity (e.g. 22/08/2010) it is output
correctly regardless of the datestyle setting.

I didn't read anything in the docs to suggest that this is expected
behaviour but I would be grateful is someone could point me in the right
direction.

Thanks,
Mark

Browse pgsql-novice by date

  From Date Subject
Next Message Basil Bourque 2011-01-18 20:52:46 How to detect if in transaction?
Previous Message Josh Kupershmidt 2011-01-18 18:03:22 Re: Question about object renaming in 9.0 (release note doc.)