pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kumar <sgnerd@yahoo.com.sg>
To: sad <sad@bankir.ru>
To: pgsql-sql@postgresql.org
Subject: Re: Getting the week of a date
Date: Tue, 17 Feb 2004 10:40:19 +0530
Message-ID: <00a401c3f514$58244970$7502a8c0@hdsc.com> (raw)
References: <00f701c3f485$d7091430$7502a8c0@hdsc.com>
	<20040216054320.32df9226.Robert_Creager@LogicalChaos.org>
	<200402161623.24195.sad@bankir.ru>

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" <sad@bankir.ru>
To: <pgsql-sql@postgresql.org>
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




view thread (7+ messages)  latest in thread

Message-ID: <00a401c3f514$58244970$7502a8c0@hdsc.com>
Permalink:  ../00a401c3f514$58244970$7502a8c0@hdsc.com/
Also on:    postgresql.org/message-id/00a401c3f514$58244970$7502a8c0@hdsc.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sgnerd@yahoo.com.sg, sad@bankir.ru
  Subject: Re: Getting the week of a date
  In-Reply-To: <00a401c3f514$58244970$7502a8c0@hdsc.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