Received: from www.actarg.com (root@[209.180.91.25]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA18028 for ; Tue, 26 Oct 1999 11:18:55 -0400 (EDT) (envelope-from kyle@actarg.com) Received: from actarg.com (root@tao.actarg.com [192.168.1.1]) by www.actarg.com (8.8.7/8.8.7) with ESMTP id JAA10863; Tue, 26 Oct 1999 09:22:38 -0600 Received: from actarg.com (kyle@chi.actarg.com [192.168.2.16]) by actarg.com (8.8.7/8.8.7) with ESMTP id JAA28501; Tue, 26 Oct 1999 09:19:30 -0600 Sender: kyle@actarg.com Message-ID: <3815C677.FA7E2675@actarg.com> Date: Tue, 26 Oct 1999 09:19:19 -0600 From: Kyle Bateman Organization: Action Target Inc X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.0.36 i686) X-Accept-Language: en MIME-Version: 1.0 To: zot@zotconsulting.com CC: pgsql-sql@postgresql.org Subject: Re: [SQL] Week of year function? Content-Type: multipart/mixed; boundary="------------E7385ED5C39B025127225365" This is a multi-part message in MIME format. --------------E7385ED5C39B025127225365 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > 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. --------------E7385ED5C39B025127225365 Content-Type: text/x-vcard; charset=us-ascii; name="kyle.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Kyle Bateman Content-Disposition: attachment; filename="kyle.vcf" 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 --------------E7385ED5C39B025127225365--