Re: auto update dates

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: "Rory Campbell-Lange" <rory(at)campbell-lange(dot)net>
Cc: "Postgresql Novice List" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: auto update dates
Date: 2002-05-24 14:42:44
Message-ID: JGEPJNMCKODMDHGOBKDNIEGOCPAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> -----Original Message-----
> From: Rory Campbell-Lange [mailto:rory(at)campbell-lange(dot)net]
> Sent: Thursday, May 23, 2002 7:25 PM
> To: Joel Burton
> Cc: Postgresql Novice List
> Subject: Re: [NOVICE] auto update dates
>
>
> On 23/05/02, Joel Burton (joel(at)joelburton(dot)com) wrote:
> > current_time returns timezone information, but you're trying to store
> > this in a field that is time w/o timezone information. either coerce
> > this data yourself, or make the field hold timezone info.
> >
> > Better question, though: why are you storing the date, the time, and
> > the timestamp? Much easier to simply store the timestamp. You can
> > always get the date & time from that. This will save you space _and_
> > time. (Plus, your current problem would become irrelevant).
>
> Hi Joel
>
> Thanks very much for your mail.
>
> I can see that working with CAST I can extract the date and
> (theoretically) the time from the timestamp. Thanks very much for the
> suggestion.
>
> brandf=# select cast(current_timestamp as time);
> ERROR: Cannot cast type 'timestamp with time zone' to 'time without
> time zone'
>
> How do I get around this? I can see various time functions with and
> without time zone data, but I don't know how to utilise them.

Rory:

SELECT cast(current_timestamp as time with time zone);

will do nicely. See the Date/Time functions in the documentation for more
help.

HTH.

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Patrick Hatcher 2002-05-24 14:48:16 Re: COPY returns Bad timestamp external rep..
Previous Message Ron Johnson 2002-05-24 14:25:58 Re: Why sequential scan when there's a supporting index?