0xBAD
0xBAD

Reputation: 31

Postgresql ISOYEAR first date

How to get the start date of ISOYEAR in postgresql?

For example, i have a date 2012-01-01, isoyear is 2011 and it isoyear starts at 2011-01-03 and ends at 2012-01-01.

There is different ways to get isoyear, but i have no idea how to get date that iso year begins.

select extract(isoyear from '01.01.2012'::date) 

select to_char('01.01.2012'::date,'IYYY')

Upvotes: 0

Views: 639

Answers (1)

Peter Eisentraut
Peter Eisentraut

Reputation: 36739

Ask it to convert the first "ISO day" of the "ISO year":

=> SELECT to_date('2011-0001', 'IYYY-IDDD');
  to_date
------------
 2011-01-03

Upvotes: 2

Related Questions