Re: [HACKERS] [GENERAL] Date conversion using day of week

2012-09-03 Thread Bruce Momjian
Patch applied. --- On Sat, Sep 1, 2012 at 05:14:39PM -0400, Bruce Momjian wrote: > [Properly posted to hackers list] > > On Fri, Apr 1, 2011 at 02:27:02AM +1100, Brendan Jurd wrote: > > On 1 April 2011 02:00, Adrian Klave

Re: [HACKERS] [GENERAL] Date conversion using day of week

2012-09-01 Thread Bruce Momjian
[Properly posted to hackers list] On Fri, Apr 1, 2011 at 02:27:02AM +1100, Brendan Jurd wrote: > On 1 April 2011 02:00, Adrian Klaver wrote: > > On Wednesday, March 30, 2011 8:39:25 pm Brendan Jurd wrote: > >> If we wanted to make it "work", then I think the thing to do would be > >> to add a ne

Re: [HACKERS] [GENERAL] Date conversion using day of week

2012-09-01 Thread Bruce Momjian
On Fri, Apr 1, 2011 at 03:58:48AM +1100, Brendan Jurd wrote: > On 1 April 2011 03:32, Adrian Klaver wrote: > > Now I am confused the docs say: > > > > D       day of the week, Sunday(1) to Saturday(7) > > ID      ISO day of the week, Monday(1) to Sunday(7) > > > > This would seem to say they both

Re: [HACKERS] [GENERAL] Date conversion using day of week

2012-09-01 Thread Bruce Momjian
On Fri, Apr 1, 2011 at 02:27:02AM +1100, Brendan Jurd wrote: > On 1 April 2011 02:00, Adrian Klaver wrote: > > On Wednesday, March 30, 2011 8:39:25 pm Brendan Jurd wrote: > >> If we wanted to make it "work", then I think the thing to do would be > >> to add a new set of formatting tokens IDY, IDA

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Brendan Jurd
On 1 April 2011 05:16, Steve Crawford wrote: > Well, to return to the original issue, should we allow the day to be spelled > out and fix it (as noted in this thread it is non-standard but also > unambiguous and we already allow plenty of non-standard formats) or throw an > error? For me personall

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Steve Crawford
On 03/31/2011 10:51 AM, Brendan Jurd wrote: I agree with your summary of the ISO standards. Unfortunately, to_date and its cohorts are not targeting ISO. They are targeting quasi-compatibility with some Oracle functions of the same name, I suppose to make life easier for folks who are migratin

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Brendan Jurd
On 1 April 2011 04:16, Steve Crawford wrote: > This whole discussion opens a #10 sized can o' worms. Admittedly, I don't > have good knowledge of any SQL-mandated interpretations of an ISO date - but > based on my reading of ISO formatting I see the following issues: > > 1. What we describe in the

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Steve Crawford
On 03/31/2011 08:00 AM, Adrian Klaver wrote: On Wednesday, March 30, 2011 8:39:25 pm Brendan Jurd wrote: On 31 March 2011 03:15, Steve Crawford wrote: On 03/29/2011 04:24 PM, Adrian Klaver wrote: ... Well the strange part is only fails for SUN:... test(5432)aklaver=>select to_date('2011-13-SU

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Brendan Jurd
On 1 April 2011 03:32, Adrian Klaver wrote: > Now I am confused the docs say: > > D       day of the week, Sunday(1) to Saturday(7) > ID      ISO day of the week, Monday(1) to Sunday(7) > > This would seem to say they both are one-based but differ on the day that is > 1. That's correct for the us

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Adrian Klaver
On 03/31/2011 08:27 AM, Brendan Jurd wrote: On 1 April 2011 02:00, Adrian Klaver wrote: On Wednesday, March 30, 2011 8:39:25 pm Brendan Jurd wrote: If we wanted to make it "work", then I think the thing to do would be to add a new set of formatting tokens IDY, IDAY etc. I don't like the idea

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Brendan Jurd
On 1 April 2011 02:35, Marc Munro wrote: > Just to be clear, the reason I was mixing things in this way was that I > wanted to validate that the dayname being passed was valid for the > current locale, and I could find no easier way of doing it. Ah, I see. In that case I think to_date would have

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Marc Munro
On Thu, 2011-03-31 at 08:00 -0700, Adrian Klaver wrote: > On Wednesday, March 30, 2011 8:39:25 pm Brendan Jurd wrote: > > On 31 March 2011 03:15, Steve Crawford > > wrote: > > > On 03/29/2011 04:24 PM, Adrian Klaver wrote: > > >> ... > > >> Well the strange part is only fails for SUN:... [. . .]

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Brendan Jurd
On 1 April 2011 02:00, Adrian Klaver wrote: > On Wednesday, March 30, 2011 8:39:25 pm Brendan Jurd wrote: >> If we wanted to make it "work", then I think the thing to do would be >> to add a new set of formatting tokens IDY, IDAY etc.  I don't like the >> idea of interpreting DY and co. differentl

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-31 Thread Adrian Klaver
On Wednesday, March 30, 2011 8:39:25 pm Brendan Jurd wrote: > On 31 March 2011 03:15, Steve Crawford wrote: > > On 03/29/2011 04:24 PM, Adrian Klaver wrote: > >> ... > >> Well the strange part is only fails for SUN:... > >> test(5432)aklaver=>select to_date('2011-13-SUN', 'IYYY-IW-DY'); > >> to_

Re: [HACKERS] [GENERAL] Date conversion using day of week

2011-03-30 Thread Brendan Jurd
On 31 March 2011 03:15, Steve Crawford wrote: > On 03/29/2011 04:24 PM, Adrian Klaver wrote: >> ... >> Well the strange part is only fails for SUN:... >> test(5432)aklaver=>select to_date('2011-13-SUN', 'IYYY-IW-DY'); >>   to_date >> >>  2011-03-28 >> ... > > You specified Sunday as t

Re: [GENERAL] Date conversion using day of week

2011-03-30 Thread Adrian Klaver
On 03/30/2011 09:15 AM, Steve Crawford wrote: On 03/29/2011 04:24 PM, Adrian Klaver wrote: ... Well the strange part is only fails for SUN:... test(5432)aklaver=>select to_date('2011-13-SUN', 'IYYY-IW-DY'); to_date 2011-03-28 ... You specified Sunday as the day but the date return

Re: [GENERAL] Date conversion using day of week

2011-03-30 Thread Steve Crawford
On 03/29/2011 04:24 PM, Adrian Klaver wrote: ... Well the strange part is only fails for SUN:... test(5432)aklaver=>select to_date('2011-13-SUN', 'IYYY-IW-DY'); to_date 2011-03-28 ... You specified Sunday as the day but the date returned is a Monday. I would categorize that as

Re: [GENERAL] Date conversion using day of week

2011-03-29 Thread Adrian Klaver
On Tuesday, March 29, 2011 9:02:52 am Steve Crawford wrote: > > But you changed it to specify an ISO year avoiding the mixed > conventions. According to the 9.0 docs > (http://www.postgresql.org/docs/9.0/static/functions-formatting.html): > > "An ISO week date (as distinct from a Gregorian dat

Re: [GENERAL] Date conversion using day of week

2011-03-29 Thread Steve Crawford
On 03/29/2011 08:50 AM, Adrian Klaver wrote: On Tuesday, March 29, 2011 8:33:59 am Steve Crawford wrote: On 03/29/2011 08:07 AM, Marc Munro wrote: I'm trying to validate a day of the week, and thought that to_date would do the job for me. But I found a case where it cannot tell the difference

Re: [GENERAL] Date conversion using day of week

2011-03-29 Thread Adrian Klaver
On Tuesday, March 29, 2011 8:33:59 am Steve Crawford wrote: > On 03/29/2011 08:07 AM, Marc Munro wrote: > > I'm trying to validate a day of the week, and thought that to_date would > > do the job for me. But I found a case where it cannot tell the > > difference between sunday and monday. Is this

Re: [GENERAL] Date conversion using day of week

2011-03-29 Thread Steve Crawford
On 03/29/2011 08:07 AM, Marc Munro wrote: I'm trying to validate a day of the week, and thought that to_date would do the job for me. But I found a case where it cannot tell the difference between sunday and monday. Is this a bug or intended behaviour? dev=# select to_date('2011-13-Mon', '

Re: [GENERAL] Date conversion using day of week

2011-03-29 Thread Adrian Klaver
On Tuesday, March 29, 2011 8:07:48 am Marc Munro wrote: > I'm trying to validate a day of the week, and thought that to_date would > do the job for me. But I found a case where it cannot tell the > difference between sunday and monday. Is this a bug or intended > behaviour? > > dev=# select to_d

[GENERAL] Date conversion using day of week

2011-03-29 Thread Marc Munro
I'm trying to validate a day of the week, and thought that to_date would do the job for me. But I found a case where it cannot tell the difference between sunday and monday. Is this a bug or intended behaviour? dev=# select to_date('2011-13-Mon', '-IW-DY'); to_date 2011-03