From: Kyle Bateman <kyle@actarg.com>
To: zot@zotconsulting.com
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Week of year function?
Date: Tue, 26 Oct 1999 09:19:19 -0600
Message-ID: <3815C677.FA7E2675@actarg.com> (raw)
> 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)?
>
I use pltcl and the following function:
-- Convert date in 1999-01-15 format to the month of the year (1999,35)
-- calling sequence: date_week(ISO_date)
drop function date_week(text);
create function date_week(text) returns text as '
set spl [split $1 {-/. }]
set year [lindex $spl 0]
set month [string trimleft [lindex $spl 1] 0]
set day [lindex $spl 2]
if {$month > 0 && $month <= 31} {
set secs [clock scan "$month/$day/$year"]
} else {
set secs [clock scan "$month $day, $year"]
}
set week [clock format $secs -format "%U"]
if {$week < 1} {
return "[expr $year - 1]-52"
}
return "$year-$week"
' LANGUAGE 'pltcl';
This has some extra stuff in it you don't need, but might demonstrate
the point.
Attachments:kyle.vcf (text/x-vcard, 290B) download
begin:vcard
n:Bateman;Kyle
tel;fax:801-377-8096
tel;work:801-377-8033x101
x-mozilla-html:FALSE
url:www.actiontarget.com
org:Action Target Inc
adr:;;PO Box 636;Provo;UT;84603;US
version:2.1
email;internet:kyle@actiontarget.com
title:President
x-mozilla-cpt:;-15520
fn:Kyle Bateman
end:vcard
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: kyle@actarg.com, zot@zotconsulting.com
Subject: Re: [SQL] Week of year function?
In-Reply-To: <3815C677.FA7E2675@actarg.com>
References: <3815C677.FA7E2675@actarg.com>
* 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