Re: Make year 01/01/0001 but leave timestamp alone

Поиск
Список
Период
Сортировка
От Walker, Jed S
Тема Re: Make year 01/01/0001 but leave timestamp alone
Дата
Msg-id 4A59B6AA01F1874283EA66C976ED51FC4663C4@COENGEXCMB01.cable.comcast.com
обсуждение исходный текст
Ответ на Make year 01/01/0001 but leave timestamp alone  ("Walker, Jed S" <Jed_Walker@cable.comcast.com>)
Ответы boolean or int2  (<operationsengineer1@yahoo.com>)
Список pgsql-novice
That's pretty clean and does the job. Thanks!

-----Original Message-----
From: John DeSoi [mailto:desoi@pgedit.com]
Sent: Tuesday, August 02, 2005 10:36 AM
To: Walker, Jed S
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Make year 01/01/0001 but leave timestamp alone


On Aug 2, 2005, at 11:49 AM, Walker, Jed S wrote:

> I have a situation where we have a timestamp column but in special
> cases we want to set the date to '01/01/0001' and leave the timestamp
> alone. For example, '11/04/2005 10:30:05' would become
> '01/01/0001 10:30:05'. I've been going through the various date time
> functions but don't see a simple way to do this. Can someone help?

select ('0001-01-01 ' || now()::time::text)::timestamp;

          timestamp
----------------------------
0001-01-01 12:31:52.815674
(1 row)


Just replace now() with whatever timestamp you are using.




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


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

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: Make year 01/01/0001 but leave timestamp alone
Следующее
От:
Дата:
Сообщение: boolean or int2