Re: [SQL] Week of year function?

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: "Zot O'Connor" <zot(at)zotconsulting(dot)com>, postgres sql <pgsql-sql(at)hub(dot)org>
Subject: Re: [SQL] Week of year function?
Date: 1999-10-25 17:14:11
Message-ID: l03130302b43a3e85e018@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

At 21:52 +0200 on 22/10/1999, Zot O'Connor wrote:

> Is there a function to return the week of the year (0-51)?

Seems you only need to divide the day of the year by seven to reach that,
don't you?

Maybe you should try:

CREATE FUNCTION week( datetime ) RETURNS int4 AS '
SELECT int( date_part( ''day'', $1 - date_trunc( ''year'', $1 ) ) ) / 7
' LANGUAGE 'sql';

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Moray McConnachie 1999-10-25 19:04:22 Re: [SQL] Week of year function?
Previous Message Rich Ryan 1999-10-25 16:39:54 Create index pretty slow