Thread: How to cast, if type has spaces in the name
How do I specify a cast, if the type name has spaces? foo::integer is easy, but foo::'timestamp without time zone' is more murky. In my case I have a table, and a view. For no apparent reason the table has timestamp without time zone, but I need timestamp with time zone. I'm using "select column at time zone 'PST8PDT'" to solve this problem. But wonder about the general case of typecasting when the type name is not a single symbol.
am Thu, dem 26.07.2007, um 0:33:09 -0700 mailte Bryce Nesbitt folgendes: > How do I specify a cast, if the type name has spaces? foo::integer is > easy, > but foo::'timestamp without time zone' is more murky. Use timestamp instead ;-) Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
am Thu, dem 26.07.2007, um 0:33:09 -0700 mailte Bryce Nesbitt folgendes: > How do I specify a cast, if the type name has spaces? foo::integer is > easy, > but foo::'timestamp without time zone' is more murky. Hehe, it works without the ', see: test=# select '2007-01-01'::timestamp without time zone; timestamp ---------------------2007-01-01 00:00:00 (1 row) test=*# select '2007-01-01'::timestamp with time zone; timestamptz ------------------------2007-01-01 00:00:00+01 (1 row) ndreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
On Thu, 26 Jul 2007, Bryce Nesbitt wrote: > How do I specify a cast, if the type name has spaces? foo::integer is > easy, > but foo::'timestamp without time zone' is more murky. foo::timestamp without time zone should work (no quotes). Another alternative if you don't like the way that looks is to use the SQL cast syntax, CAST(foo AS timestamp without time zone).