Extract giving wrong week of year

From: Ben Primrose <bprimrose(at)tracelink(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Extract giving wrong week of year
Date: 2015-09-25 20:54:28
Message-ID: df5f54d230b61e4d6a3c9161c3f7ca06@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

All,

I’m seeing some odd behavior from the extract function.
Any idea why extract would think January 3rd of next year is the 53rd week
of the year?

Thanks

Ben

[bprimrose(at)primrose partitioning]$ psql

Null display is "¤".

Line style is unicode.

Output format is wrapped.

Timing is on.

psql (9.3.9)

Type "help" for help.

bprimrose(at)home=> select extract (week from '2016-01-03
00:01:00'::timestamp);

date_part

───────────

53

(1 row)

Time: 1.128 ms

bprimrose(at)home=> select version();

version

─────────────────────────────────────────────────────────────────────────────────────────────────────────────

PostgreSQL 9.3.9 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.9.2
20150212 (Red Hat 4.9.2-6), 64-bit

(1 row)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-09-25 21:01:17 Re: Extract giving wrong week of year
Previous Message Raymond Brinzer 2015-09-25 18:23:02 Re: Automatically Updatable Foreign Key Views