pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Zot O'Connor <zot@zotconsulting.com>
To: postgres sql <pgsql-sql@hub.org>
Subject: Re: [SQL] Week of year function?
Date: Mon, 25 Oct 1999 19:14:11 +0200
Message-ID: <l03130302b43a3e85e018@[147.233.159.109]> (raw)
In-Reply-To: <3810C061.9E2DCE6C@zotconsulting.com>

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





view thread (7+ messages)  latest in thread

Message-ID: <l03130302b43a3e85e018@[147.233.159.109]>
Permalink:  ../l03130302b43a3e85e018@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130302b43a3e85e018@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, zot@zotconsulting.com, pgsql-sql@hub.org
  Subject: Re: [SQL] Week of year function?
  In-Reply-To: <l03130302b43a3e85e018@[147.233.159.109]>
  References: <3810C061.9E2DCE6C@zotconsulting.com> <l03130302b43a3e85e018@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox