Thread: ECPG date output depends on database datestyle

ECPG date output depends on database datestyle

From
Mark Smith
Date:
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