pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Keith Worthington <keithw@narrowpathinc.com>
To: 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, 2 Aug 2005 12:14:56 -0400
Message-ID: <20050802161204.M17641@narrowpathinc.com> (raw)
In-Reply-To: <4A59B6AA01F1874283EA66C976ED51FC4663BB@COENGEXCMB01.cable.comcast.com>
References: <4A59B6AA01F1874283EA66C976ED51FC4663BB@COENGEXCMB01.cable.comcast.com>

On Tue, 2 Aug 2005 09:49:19 -0600, 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?
> 
> Thanks,
> 
> Jed

Jed,

There may be a more elegant way to do it but this is the first thing that lept
to my mind.

SELECT '01/01/0001'::date,
       now()::time,
       (    '01/01/0001'::date::varchar
         || ' '
         || now()::time::varchar
       )::timestamp;

Kind Regards,
Keith



view thread (5+ messages)  latest in thread

Message-ID: <20050802161204.M17641@narrowpathinc.com>
Permalink:  ../20050802161204.M17641@narrowpathinc.com/
Also on:    postgresql.org/message-id/20050802161204.M17641@narrowpathinc.com

 · 

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: keithw@narrowpathinc.com, Jed_Walker@cable.comcast.com, pgsql-novice@postgresql.org
  Subject: Re: Make year 01/01/0001 but leave timestamp alone
  In-Reply-To: <20050802161204.M17641@narrowpathinc.com>

* 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