pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: John DeSoi <desoi@pgedit.com>
Cc: Walker, Jed S <Jed_Walker@cable.comcast.com>
Cc: pgsql-novice@postgresql.org
Subject: Re: Make year 01/01/0001 but leave timestamp alone
Date: Tue, 02 Aug 2005 16:57:09 -0400
Message-ID: <24440.1123016229@sss.pgh.pa.us> (raw)
In-Reply-To: <C4C31703-544A-45D1-999A-46C7A4BF4B9D@pgedit.com>
References: <4A59B6AA01F1874283EA66C976ED51FC4663BB@COENGEXCMB01.cable.comcast.com>
	<C4C31703-544A-45D1-999A-46C7A4BF4B9D@pgedit.com>

John DeSoi <desoi@pgedit.com> writes:
> 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;

This textual pasting makes me itch ... try something like

select '0001-01-01'::timestamp + now()::time;
          ?column?
----------------------------
 0001-01-01 16:56:16.313866
(1 row)


			regards, tom lane



view thread (5+ messages)

Message-ID: <24440.1123016229@sss.pgh.pa.us>
Permalink:  ../24440.1123016229@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24440.1123016229@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, desoi@pgedit.com, Jed_Walker@cable.comcast.com, pgsql-novice@postgresql.org
  Subject: Re: Make year 01/01/0001 but leave timestamp alone
  In-Reply-To: <24440.1123016229@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox