X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1C004D1D8F3 for ; Tue, 17 Feb 2004 05:46:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 22659-03 for ; Tue, 17 Feb 2004 01:46:13 -0400 (AST) Received: from smtp101.mail.sc5.yahoo.com (smtp101.mail.sc5.yahoo.com [216.136.174.139]) by svr1.postgresql.org (Postfix) with SMTP id DFDDED1D8B7 for ; Tue, 17 Feb 2004 01:46:11 -0400 (AST) Received: from unknown (HELO IVESIA67) (sgnerd@203.196.190.138 with login) by smtp101.mail.sc5.yahoo.com with SMTP; 17 Feb 2004 05:46:11 -0000 Message-ID: <00de01c3f519$743406a0$7502a8c0@hdsc.com> Reply-To: "Kumar" From: "Kumar" To: "sad" , References: <00f701c3f485$d7091430$7502a8c0@hdsc.com> <20040216054320.32df9226.Robert_Creager@LogicalChaos.org> <200402161623.24195.sad@bankir.ru> <00a401c3f514$58244970$7502a8c0@hdsc.com> Subject: Re: Getting the week of a date Date: Tue, 17 Feb 2004 11:16:53 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/205 X-Sequence-Number: 16895 I am sorry. I didn't read the doc properly. I understood why it is written in that way. Sorry for the trouble. Thanks. It worked fine for me. Thanks Kumar ----- Original Message ----- From: "Kumar" To: "sad" ; Sent: Tuesday, February 17, 2004 10:40 AM Subject: Re: [SQL] Getting the week of a date > Seems a part of your function always returns '0' > select 1 - (to_char(date_trunc('month',now()),'D'))::INT2 > > because while we use date_trunc it will always return the first day of the > month and when it get subtracted by '1' it be always zero. Is there any > reason why you have included that? > > Thanks > Kumar > > ----- Original Message ----- > From: "sad" > To: > Sent: Monday, February 16, 2004 6:53 PM > Subject: Re: [SQL] Getting the week of a date > > > EXCUSE ME, GUYS ! > > i forgot to add one monome: > 7*(((to_char(date_trunc('month',now()),'D'))::INT2-1)/4) > which is stands for skip a first week of month in case it is not consist Wed > > finally the select will be similar the following > > SELECT 7*(((to_char(date_trunc('month',now()),'D'))::INT2-1)/4) + 1 - > (to_char(date_trunc('month',now()),'D'))::INT2 + 7*3-3 ; > > 4 - is a number of Wed in a week (in postgresql numeration) > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster