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

Re: How can I get the first and last date of a week, based on the week number and the year

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruno Baguette <bruno(dot)baguette(at)gmail(dot)com>
Subject: Re: How can I get the first and last date of a week, based on the week number and the year
Date: 2008-02-27 06:07:56
Message-ID: 200802262207.56407.aklaver@comcast.net (view raw or flat)
Thread:
Lists: pgsql-general
On Tuesday 26 February 2008 8:39 pm, Tom Lane wrote:
> Adrian Klaver <aklaver(at)comcast(dot)net> writes:
> > On Tuesday 26 February 2008 5:32 pm, Bruno Baguette wrote:
> >> I have a week number (ISO 8601) and a year, based on theses values, I
> >> would like to get the first and the last dates of that week.
> >
> > This will get you to the Monday of the week .
> >
> > select to_date('9  08','IW  YY');
> >   to_date
> > ------------
> >  2008-02-25
> > (1 row)
>
> date_trunc('week', ...) would probably be a more convenient way of doing
> that.
>
> 			regards, tom lane

I am not sure I follow. The OP has a ISO week number and a year and wants 
dates. I thought date_trunc('field',source) requires a timestamp or interval 
as its source. 
-- 
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Responses

pgsql-general by date

Next:From: Tom LaneDate: 2008-02-27 06:13:23
Subject: Re: How can I get the first and last date of a week, based on the week number and the year
Previous:From: Hiroshi SaitoDate: 2008-02-27 04:44:38
Subject: Re: UUID-OSSP for windows.

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