Thread: timestamp parse error
Hello! i'm using PostgreSQL 7.2.1 and got strange parse errors.. could somebody tell me what's wrong with this timestamp query example? PostgreSQL said: ERROR: parser: parse error at or near "date" Your query: select timestamp(date '1998-02-24', time '23:07') example is from PostgreSQL help and certainly worked in previous versions of pgsql.. but in 7.2.1 it does not. had anything changed and not been updated in pgsql manuals or is it a bug? thanx for any help Tomas Lehuta
On Fri, 20 Sep 2002, Tomas Lehuta wrote: > Hello! > > i'm using PostgreSQL 7.2.1 and got strange parse errors.. > could somebody tell me what's wrong with this timestamp query example? > > PostgreSQL said: ERROR: parser: parse error at or near "date" > Your query: > > select timestamp(date '1998-02-24', time '23:07') > > example is from PostgreSQL help and certainly worked in previous versions of > pgsql.. but in 7.2.1 it does not. had anything changed and not been updated > in pgsql manuals or is it a bug? Presumably it's a manual example that didn't get changed. Timestamp(...) is now a specifier for the type with a given precision. You can use "timestamp"(date '1998-02-24', time '23:07') or datetime math (probably something like date '1998-02-24' + time '23:07' and possibly a cast)
"Tomas Lehuta" <lharp@aurius.sk> writes: > could somebody tell me what's wrong with this timestamp query example? > select timestamp(date '1998-02-24', time '23:07') > PostgreSQL said: ERROR: parser: parse error at or near "date" > example is from PostgreSQL help From where exactly? I don't see any such example in current sources. Although you could make this work by double-quoting the name "timestamp" (which is a reserved word now, per SQL spec), I'd recommend sidestepping the problem by using the equivalent + operator instead: regression=# select "timestamp"(date '1998-02-24', time '23:07'); timestamp --------------------- 1998-02-24 23:07:00 (1 row) regression=# select date '1998-02-24' + time '23:07'; ?column? --------------------- 1998-02-24 23:07:00 (1 row) regards, tom lane