Обсуждение: 7.2b Timestamp
Has some thing changed with the timestamp function since 7.0
7.0
create table t (i int);
insert into t values(1);
select timestamp(date '1998-02-24', time '23:07') from t;
timestamp
------------------------
1998-02-24 23:07:00-05
(1 row)
7.2 b
create table t (i int);
insert into t values(1);
select timestamp(date '1998-02-24', time '23:07') from t;
ERROR: parser: parse error at or near "date"
I'm asuming it changed in 7.2 because the 7.1 docs show the usage the
same as 7.0 (or the docs are wrong ;-) )
Dave Smith <dave@candata.com> writes:
> Has some thing changed with the timestamp function since 7.0
The word "timestamp" is more reserved than it used to be, because
7.2 adds support for SQL92 timestamp precision options ---
timestamp(6) is now a type name, not a function call.
This means you need to write
select "timestamp"(date '1998-02-24', time '23:07');
to get the result you are after. Pain in the neck, I agree.
Actually, if the result you are after is timestamp with time zone,
you might try
select timestamptz(date '1998-02-24', time '23:07');
to avoid needing quotes.
regards, tom lane
> This means you need to write
> select "timestamp"(date '1998-02-24', time '23:07');
Less painful might be to use a different syntax:
select (date '1998-02-24' + time '23:07');
should do what you need. Other places where you might be tempted to use
a function call to accomplish type conversion might be handled using the
CAST() function or operator.
- Thomas