Re: [SQL] Week to date function

2010-03-31 Thread Jasen Betts
On 2010-03-27, Hiltibidal, Rob wrote: > U only 52 calendar weeks in a year... I'm almost sure that is the > norm All hours have 60 minutes All weeks have 7 days All years have 12 months all else is variable. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to

Re: [SQL] Week to date function

2010-03-30 Thread Hiltibidal, Rob
l-sql@postgresql.org Subject: Re: [SQL] Week to date function Jorge Godoy pisze: > Are you sure? > > http://en.wikipedia.org/wiki/ISO_8601 snip > > As Jan 1st, 2010 happened on a Friday, it was on week 53 of 2009. you are right, thanks for pointing that out. I didn't check t

Re: [SQL] Week to date function

2010-03-27 Thread Jorge Godoy
It isn't. The norm is defined by ISO 8601. There is a lot of "fun" into date calculations. The rule is to counts the number of Thursdays on a year to get the correct number of weeks. What bothers me more is that here it is cultural that weeks start on Sunday, but ISO 8601 says they start on Mon

Re: [SQL] Week to date function

2010-03-27 Thread Ireneusz Pluta
Jorge Godoy pisze: Are you sure? http://en.wikipedia.org/wiki/ISO_8601 snip As Jan 1st, 2010 happened on a Friday, it was on week 53 of 2009. you are right, thanks for pointing that out. I didn't check the opposite way like this: select date_part('week', '2010-01-01'::date); date_part

Re: [SQL] Week to date function

2010-03-27 Thread Jorge Godoy
Are you sure? http://en.wikipedia.org/wiki/ISO_8601 Week dates Main article: ISO week date *-Www* *or* *Www* *-Www-D* *or* *WwwD* Week date representations are in the format as shown in the box to the right. [] indicates the *I

Re: [SQL] Week to date function

2010-03-26 Thread Ireneusz Pluta
Sergey Konoplev pisze: CREATE OR REPLACE FUNCTION your_week2date(double precision, double precision) RETURNS SETOF date AS $_$ SELECT day FROM ( SELECT ( date_trunc('week', ($1::text||'-01-01')::date) + ($2::text||' week')::interval + ( d::text||' da

Re: [SQL] Week to date function

2010-03-26 Thread Sergey Konoplev
> CREATE OR REPLACE FUNCTION your_week2date(double precision, double > precision) RETURNS SETOF date > AS > $_$ > SELECT  day > FROM ( >   SELECT  ( >               date_trunc('week', ($1::text||'-01-01')::date) >               + ($2::text||' week')::interval >               + ( d::text||'  day')::

Re: [SQL] Week to date function

2010-03-26 Thread Ireneusz Pluta
Sergey Konoplev pisze: On 25 March 2010 12:25, Ireneusz Pluta wrote: Hello, is there any standard function, or a concise solution based on set of them, returning a set of dates included in a week of given year and week number? I ended up with creating my own function as in the example below

Re: [SQL] Week to date function

2010-03-25 Thread Sergey Konoplev
On 25 March 2010 12:25, Ireneusz Pluta wrote: > Hello, > > is there any standard function, or a concise solution based on set of them, > returning a set of dates included in a week of given year and week number? > I ended up with creating my own function as in the example below, but I am > curious