Re: Getting the week of a date

From: "Kumar" <sgnerd(at)yahoo(dot)com(dot)sg>
To: "sad" <sad(at)bankir(dot)ru>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Getting the week of a date
Date: 2004-02-17 05:46:53
Message-ID: 00de01c3f519$743406a0$7502a8c0@hdsc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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" <sgnerd(at)yahoo(dot)com(dot)sg>
To: "sad" <sad(at)bankir(dot)ru>; <pgsql-sql(at)postgresql(dot)org>
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" <sad(at)bankir(dot)ru>
> To: <pgsql-sql(at)postgresql(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Karsten Hilbert 2004-02-17 09:08:41 Re: Tip: a function for creating a remote view using dblink
Previous Message Kumar 2004-02-17 05:10:19 Re: Getting the week of a date