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

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: "Walker, Jed S" <Jed_Walker(at)cable(dot)comcast(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Make year 01/01/0001 but leave timestamp alone
Date: 2005-08-02 16:14:56
Message-ID: 20050802161204.M17641@narrowpathinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message daq 2005-08-02 16:22:27 Re: [NOVICE] Make year 01/01/0001 but leave timestamp alone
Previous Message Walker, Jed S 2005-08-02 15:49:19 Make year 01/01/0001 but leave timestamp alone

Browse pgsql-sql by date

  From Date Subject
Next Message daq 2005-08-02 16:22:27 Re: [NOVICE] Make year 01/01/0001 but leave timestamp alone
Previous Message Walker, Jed S 2005-08-02 15:49:19 Make year 01/01/0001 but leave timestamp alone