Skip site navigation (1) Skip section navigation (2)

Re: changing datestyle

From: Karl Nack <karlnack(at)futurityinc(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: changing datestyle
Date: 2009-06-16 17:28:28
Message-ID: alpine.DEB.1.10.0906161207510.20782@mindinao (view raw or flat)
Thread:
Lists: pgsql-novice
>> And yet datestyle continues to come back as 'ISO, MDY'.
>
> That's exactly what it should do.  'US' is a synonym for 'MDY',
> and in any case it determines only one of the two components
> of DateStyle.
>
> (The fact that there are two components is a historical aberration,
> and I'd be the first to agree it's ugly, but that's how it works.)

My understanding is that the first component indicates how dates are 
output by default, the second how dates are interpreted upon input 
(to disambiguate between MDY and DMY).

If this is correct (I'm beginning to think it's not), I'd like something 
like 'MDY, MDY', where dates are output as MDY by default (instead of 
ISO). That way I don't have to keep writing queries like "SELECT 
to_char(date_field, 'MM/DD/YYYY') FROM some_table"

> You need to read the manual a bit more closely, perhaps; or at
> least explain what your *actual* problem is.

Running the following, either directly in psql or upon connecting from a
webserver (php specifically), doesn't change the datestyle setting:
SET datestyle = 'US'
SET datestyle = 'MDY'
SET datestyle = 'MDY, MDY'

I was expecting it to change to something like 'MDY, MDY'.

Obviously I'm missing something here, just not sure what!


Karl Nack

Futurity, Inc.
773-506-2007


In response to

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2009-06-16 17:36:01
Subject: Re: changing datestyle
Previous:From: Tom LaneDate: 2009-06-16 13:44:32
Subject: Re: changing datestyle

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group