Re: converting a specified year and week into a date

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: converting a specified year and week into a date
Дата
Msg-id 20070214073652.GD1303@a-kretschmer.de
обсуждение исходный текст
Ответ на converting a specified year and week into a date  (vanessa <vanessaknell@gmail.com>)
Ответы Re: converting a specified year and week into a date  (Ron Johnson <ron.l.johnson@cox.net>)
Список pgsql-general
am  Tue, dem 13.02.2007, um 13:56:15 -0800 mailte vanessa folgendes:
>
> hi guys,
> i was just wondering if it was at all possible to turn a year and a given
> week number into a real date just using postgresql commands?
>
>
> e.g. if i have year = 2004 and week = 1,
>     can i turn that into say 2004-01-01 (so that the specified
>     date is the one for the beginning of week 1 in the year 2004

You can extract the week from a given date with this:

SELECT EXTRACT(WEEK FROM '2006-01-01'::date);

Be careful, the 1.1. can be in the 52. week in the last year. If you
know the first day in the year in week 1, then you can add 7* the given
week-1 days to this date.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

В списке pgsql-general по дате отправления:

Предыдущее
От: Chris
Дата:
Сообщение: Re: Problem with 'tr' command
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Timestamp/Timezone - does this make sense?