Re: Getting the week of a date

Поиск
Список
Период
Сортировка
От sad
Тема Re: Getting the week of a date
Дата
Msg-id 200402161608.52404.sad@bankir.ru
обсуждение исходный текст
Ответ на Getting the week of a date  ("Kumar" <sgnerd@yahoo.com.sg>)
Список 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 по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Getting the week of a date
Следующее
От: "Mark Roberts"
Дата:
Сообщение: Date format problems