Re: Getting the week of a date - Mailing list pgsql-sql

From sad
Subject Re: Getting the week of a date
Date
Msg-id 200402161608.52404.sad@bankir.ru
Whole thread Raw
In response to Getting the week of a date  ("Kumar" <sgnerd@yahoo.com.sg>)
List pgsql-sql
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 (factor 3 is a desired week number)
-3 is number of days to step back from sunday to a desired day of week
(-3 stands for Wed)




pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Getting the week of a date
Next
From: "Mark Roberts"
Date:
Subject: Date format problems