ISO year.

Started by Kurt Roeckxover 22 years ago13 messagespatches
Jump to latest
#1Kurt Roeckx
Q@ping.be

This patch allows you to use IYYYY as format specifier to get the
ISO year, the year correspondeing to the ISO week number (IW).

Kurt

Attachments:

isoyear.difftext/plain; charset=us-asciiDownload+193-1
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kurt Roeckx (#1)
Re: ISO year.

Kurt Roeckx <Q@ping.be> writes:

This patch allows you to use IYYYY as format specifier to get the
ISO year, the year correspondeing to the ISO week number (IW).

The purpose of to_char() as I understand it is to be 100% Oracle
compatible, not to invent new features at random. Is this duplicating
some Oracle functionality that was left out?

regards, tom lane

#3Kurt Roeckx
Q@ping.be
In reply to: Tom Lane (#2)
Re: ISO year.

On Thu, Dec 18, 2003 at 11:41:18AM -0500, Tom Lane wrote:

Kurt Roeckx <Q@ping.be> writes:

This patch allows you to use IYYYY as format specifier to get the
ISO year, the year correspondeing to the ISO week number (IW).

The purpose of to_char() as I understand it is to be 100% Oracle
compatible, not to invent new features at random. Is this duplicating
some Oracle functionality that was left out?

I have no idea if this in Oracle or not. But it's something I
needed, and other people in the past asked about it too.

You could use the normal year instead of the iso year, but around
newyear this always gives problems.

Kurt

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Kurt Roeckx (#3)
Re: ISO year.

Kurt Roeckx wrote:

I have no idea if this in Oracle or not. But it's something I
needed, and other people in the past asked about it too.

It is in Oracle, but you aren't exactly on the spot. It should be

IYYY - 4 digits ('2003')
IYY - 3 digits ('003')
IY - 2 digits ('03')
I - 1 digit ('3')

#5Kurt Roeckx
Q@ping.be
In reply to: Peter Eisentraut (#4)
Re: ISO year.

On Thu, Dec 18, 2003 at 06:47:41PM +0100, Peter Eisentraut wrote:

Kurt Roeckx wrote:

I have no idea if this in Oracle or not. But it's something I
needed, and other people in the past asked about it too.

It is in Oracle, but you aren't exactly on the spot. It should be

IYYY - 4 digits ('2003')
IYY - 3 digits ('003')
IY - 2 digits ('03')
I - 1 digit ('3')

I'll update the patch to support all of them.

Kurt

#6Kurt Roeckx
Q@ping.be
In reply to: Peter Eisentraut (#4)
Re: ISO year.

On Thu, Dec 18, 2003 at 06:47:41PM +0100, Peter Eisentraut wrote:

Kurt Roeckx wrote:

I have no idea if this in Oracle or not. But it's something I
needed, and other people in the past asked about it too.

It is in Oracle, but you aren't exactly on the spot. It should be

IYYY - 4 digits ('2003')
IYY - 3 digits ('003')
IY - 2 digits ('03')
I - 1 digit ('3')

Here is an updated patch that does that.

Kurt

Attachments:

isoyear-2.difftext/plain; charset=us-asciiDownload+217-7
#7Karel Zak
zakkr@zf.jcu.cz
In reply to: Kurt Roeckx (#1)
Re: ISO year.

On Thu, Dec 18, 2003 at 04:33:44PM +0100, Kurt Roeckx wrote:

+ DCH_IYYYY,

^^^^^^^^^^^

DCH_YYYY,
DCH_YYY,
DCH_YY,

There is a bug.. it's wrong position. Please, add the "enum" of
DCH_IYYYY to same position as you have "IYYYY" in next array. It means
"enum" DCH_IYYYY must be behind DCH_IW. If you will add others IY the
order must be:

DCH_IW
DCH_IYYYY
DCH_IYYY
DCH_IYY
DCH_IY

.. and same for lower case version:

@@ -582,6 +583,7 @@
DCH_ww,
DCH_w,
DCH_y_yyy,
+ DCH_iyyyy,

^^^^^^^^^

Thanks!
Karel

--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

#8Karel Zak
zakkr@zf.jcu.cz
In reply to: Tom Lane (#2)
Re: ISO year.

On Thu, Dec 18, 2003 at 11:41:18AM -0500, Tom Lane wrote:

Kurt Roeckx <Q@ping.be> writes:

This patch allows you to use IYYYY as format specifier to get the
ISO year, the year correspondeing to the ISO week number (IW).

The purpose of to_char() as I understand it is to be 100% Oracle
compatible, not to invent new features at random. Is this duplicating
some Oracle functionality that was left out?

Oracle has IYYYY too. So thanks to Kurt, because now we approximate to
100% compatibity :-)

BTW, I'm open for to_char() PostgreSQL extensions if it will good
described in docs and marked as PostgreSQL extension.

Karel

--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

#9Karel Zak
zakkr@zf.jcu.cz
In reply to: Kurt Roeckx (#6)
Re: ISO year.

On Thu, Dec 18, 2003 at 08:18:08PM +0100, Kurt Roeckx wrote:

DCH_IW,
+	DCH_IYYY,
+	DCH_IYY,
+	DCH_IY,
+	DCH_I,

It's better :-) This patch is OK for me.

Karel

--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

#10Bruce Momjian
bruce@momjian.us
In reply to: Karel Zak (#9)
Re: ISO year.

Karel Zak wrote:

On Thu, Dec 18, 2003 at 08:18:08PM +0100, Kurt Roeckx wrote:

DCH_IW,
+	DCH_IYYY,
+	DCH_IYY,
+	DCH_IY,
+	DCH_I,

It's better :-) This patch is OK for me.

Which patch is OK? The one attached? You looked like you were making
changes to this patch in your later emails.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/bjm/33text/plainDownload+217-7
In reply to: Bruce Momjian (#10)
Re: ISO year.

On Fri, Dec 19, 2003 at 07:14:53PM -0500, Bruce Momjian wrote:

Which patch is OK? The one attached? You looked like you were making
changes to this patch in your later emails.

That is the changed/good patch.

Kurt

#12Bruce Momjian
bruce@momjian.us
In reply to: Kurt Roeckx (#6)
Re: ISO year.

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Kurt Roeckx wrote:

On Thu, Dec 18, 2003 at 06:47:41PM +0100, Peter Eisentraut wrote:

Kurt Roeckx wrote:

I have no idea if this in Oracle or not. But it's something I
needed, and other people in the past asked about it too.

It is in Oracle, but you aren't exactly on the spot. It should be

IYYY - 4 digits ('2003')
IYY - 3 digits ('003')
IY - 2 digits ('03')
I - 1 digit ('3')

Here is an updated patch that does that.

Kurt

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#13Bruce Momjian
bruce@momjian.us
In reply to: Kurt Roeckx (#6)
Re: ISO year.

Patch applied. Thanks.

---------------------------------------------------------------------------

Kurt Roeckx wrote:

On Thu, Dec 18, 2003 at 06:47:41PM +0100, Peter Eisentraut wrote:

Kurt Roeckx wrote:

I have no idea if this in Oracle or not. But it's something I
needed, and other people in the past asked about it too.

It is in Oracle, but you aren't exactly on the spot. It should be

IYYY - 4 digits ('2003')
IYY - 3 digits ('003')
IY - 2 digits ('03')
I - 1 digit ('3')

Here is an updated patch that does that.

Kurt

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073