L PROTECTED]>
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
ason why you have included that?
Thanks
Kumar
- Original Message -
From: "sad" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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*(
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
On Monday 16 February 2004 12:10, Kumar wrote:
>
> test=# select date_trunc('week',current_date + ('5 month')::INTERVAL);
> ERROR: TIMESTAMP units 'week' not supported
Try EXTRACT(week FROM ...)
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
On Monday 16 February 2004 15:10, you wrote:
>
> Any idea on how to find the 3 rd Wednesday of any given month.
SELECT
1-(to_char(date_trunc('month', now()::timestamp),'D'))::INT2 + 7*3-3
replace now with any date and you'll the the day number of a third Wed in that
month.
7 is a constant (fac
When grilled further on (Mon, 16 Feb 2004 17:40:08 +0530),
"Kumar" <[EMAIL PROTECTED]> confessed:
> Dear Friends,
>
> Postgres 7.3.4 on RH Linux7.2.
>
> While this works for month and why not for week
>
date_trunc (obviously) doesn't support week. I ran into this a while ago, and
came up with
Dear Friends,
Postgres 7.3.4 on RH Linux7.2.
While this works for month and why not for
week
test=# select date_trunc('month',current_date + ('5
month')::INTERVAL);
date_trunc- 2004-07-01 00:00:00(1
row)
test=# select date_trunc('week',current_date + ('5
month'