Re: Combine Date and Time Columns to Timestamp

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Combine Date and Time Columns to Timestamp
Дата
Msg-id 20130119154049.108990@gmx.com
обсуждение исходный текст
Ответ на Combine Date and Time Columns to Timestamp  (Rich Shepard <rshepard@appl-ecosys.com>)
Ответы Re: Combine Date and Time Columns to Timestamp  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
Список pgsql-general
Rich Shepard wrote:
> On Fri, 18 Jan 2013, Adrian Klaver wrote:
>
>> test=> SELECT ('2012-10-29 '||'10:19')::timestamp;
>> timestamp
>> ---------------------
>> 2012-10-29 10:19:00
>
>  Thanks, Adrian. I suspected it was simple but I could not find a reference
> to the syntax.

Of course, since you appear to want to deal with moments in time,
timestamptz is more appropriate than just timestamp. If the values
are in UTC, then you will want to append that to the string. You
might use something like:

test=# SELECT ('2012-10-29 '||'10:19'||' +00')::timestamptz;
      timestamptz      
------------------------
 2012-10-29 05:19:00-05
(1 row)

If they're not already in UTC and your locale has a seasonal offset
like Daylight Saving Time, you might want to be careful with how
you handle data around the autumnal shift, or you could have things
which finish before they started.

-Kevin


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

Предыдущее
От: Raghavendra
Дата:
Сообщение: Re: Cannot install postgres 9.2, less than 32 MB of memory
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Cannot install postgres 9.2, less than 32 MB of memory