Thread: problem with a column of type timestamp

problem with a column of type timestamp

From
Sascha Bohnenkamp
Date:
Hi,

I have a table of type timestamp.
I get the following error when I try to insert som edata to it:

PGRES_FATAL_ERROR
column "birthtime" is of type timestamp without time zone but expression
is of type time without time zone  You will need to rewrite or cast the
expression.

how can I set the timezone?

Re: problem with a column of type timestamp

From
brian
Date:
Sascha Bohnenkamp wrote:
> Hi,
>
> I have a table of type timestamp.
> I get the following error when I try to insert som edata to it:
>
> PGRES_FATAL_ERROR
> column "birthtime" is of type timestamp without time zone but expression
> is of type time without time zone  You will need to rewrite or cast the
> expression.
>

Sascha, the error is occuring because you are not including the date for
column birthtime. A timestamp column expects both a date and a time, eg:

2007-10-16 12:22:53

It appears as if you are attempting to insert just the '12:22:53' part.
If you prepend the date to that it should work just fine.

http://www.postgresql.org/docs/8.0/static/datatype-datetime.html

 > how can I set the timezone?
 >

The timezone is irrelevant to the problem. But if you do wish to store
the timezone, you'll have to alter the column so that it expects it.

ALTER TABLE your_table ALTER COLUMN birthtime TIMESTAMP WITH TIMEZONE;

http://www.postgresql.org/docs/8.0/static/sql-altertable.html

brian

Re: problem with a column of type timestamp

From
Michael Glaesemann
Date:
On Oct 16, 2007, at 1:55 , Sascha Bohnenkamp wrote:

> PGRES_FATAL_ERROR
> column "birthtime" is of type timestamp without time zone but
> expression
> is of type time without time zone  You will need to rewrite or cast
> the
> expression.
>
> how can I set the timezone?

The issue isn't the time zone: I believe it's that one is a
*timestamp* while the other is a *time*;

Michael Glaesemann
grzm seespotcode net