From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Zot O'Connor <zot@zotconsulting.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Week of year function?
Date: Tue, 26 Oct 1999 12:33:55 +0200
Message-ID: <l03130300b43b2e7ab424@[147.233.159.109]> (raw)
In-Reply-To: <3814A06B.3BB61BA0@zotconsulting.com>
References: <l03130302b43a3e85e018@[147.233.159.109]>
At 20:24 +0200 on 25/10/1999, Zot O'Connor wrote:
> Herouth Maoz wrote:
> >
> > 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?
> >
>
> BTW I ought to offset the year to some standard too since Jan1 is not a
> sunday. I know Intel starts work week 1 in dec this work year.
That's why I asked whether you only needed to divide by seven. It depends
on your definition of "a week". If you define a week as "seven consecutive
days", then in a year with 365 or 366 days you will always have 53 weeks,
the last of which being a short one. If you define a week as "Monday to
Sunday", or "Sunday to Saturday" (this is culture-dependent), then you may
even have 54 weeks per year (52 full weeks, a weekend in the beginning, and
the beginning of a week in the end - but only in a leap year). This
complicates the calculation a bit. You probably have to subtract the
day-of-week (0-7) oy January first from it, and then subtract the resulting
date from your $1, and divide by 7.
This is true in places where the week's first day is Sunday.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
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
Subject: Re: [SQL] Week of year function?
In-Reply-To: <l03130300b43b2e7ab424@[147.233.159.109]>
References: <l03130302b43a3e85e018@[147.233.159.109]> <l03130300b43b2e7ab424@[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