Thread: Ignored PostgreSQL SET command
I have a line in a PHP script that looks like this: $set=pg_exec($dbconn, "SET DATESTYLE TO 'European'"); //Set date format Since my ISP updated their server, this appears to be ignored as pgsql always returns dates in ISO format. 1. What is the default format of dates returned that I can ALWAYS rely on? 2. Why is the command ignored? ======================================================================= Patrick Dunford, Christchurch, NZ - http://pdunford.godzone.net.nz/ There is no wisdom, no insight, no plan that can succeed against the LORD. -- Proverbs 21:30 http://www.heartlight.org/cgi-shl/todaysverse.cgi?day=20010101 ======================================================================= Created by Mail2Sig - http://pdunford.godzone.net.nz/software/mail2sig/
> I have a line in a PHP script that looks like this: > $set=pg_exec($dbconn, "SET DATESTYLE TO 'European'"); //Set date format > Since my ISP updated their server, this appears to be ignored as pgsql > always returns dates in ISO format. > 1. What is the default format of dates returned that I can ALWAYS rely on? ISO. Or you can start up the backend with a different default. > 2. Why is the command ignored? It is not (or, is probably not). The variant "European" affects month and day ordering when specifying a date or when formatting a date with the "Postgres" or "SQL" format. You probably want SET DATESTYLE TO 'SQL,European' but ymmv. Check out the docs for more complete info, specifically the chapter on data types. - Thomas
"Patrick Dunford" wrote: >I have a line in a PHP script that looks like this: > > $set=pg_exec($dbconn, "SET DATESTYLETO 'European'"); //Set date format > >Since my ISP updated their server, this appears to be ignored as pgsql >alwaysreturns dates in ISO format. > >1. What is the default format of dates returned that I can ALWAYS rely on? From release 7, the default format is ISO: yyyy-mm-dd >2. Why is the command ignored? European has no meaning with the ISO datestyle. To get normal European dates, do this SET command: SET DATESTYLE TO 'Postgres,European' -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47 GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Verily, verily, I say unto you, He that heareth my word, and believeth onhim that sent me, hath everlasting life, and shall not come into condemnation; but is passed from death untolife." John 5:24