| From: | stig erikson <stigerikson_nospam_(at)yahoo(dot)se> |
|---|---|
| To: | pgsql-docs(at)postgresql(dot)org |
| Subject: | type casting reference? |
| Date: | 2005-06-12 19:39:28 |
| Message-ID: | d8i30k$25ij$1@news.hub.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-docs |
hi.
i need to cast from timestamp to seconds (in the form of integer).
i have a table with a column:
expiretime timestamp
i have tried the following, it gives errors as below:
SELECT expiretime::float4 AS timeleft FROM table WHERE something='1234';
ERROR: cannot cast type timestamp without time zone to real
SELECT expiretime::text::float4 AS timeleft FROM table WHERE something='1234';
ERROR: invalid input syntax for type real: "2005-06-12 21:21:24.368082"
postgresql 7.4.1 (i know, old)
so, my question is simply, where in the docs can i find how i should perform the
cast?
it would help a lot if there was a table showing which types can be cased into
which, and possibly an example or two for situations like this, casting from
timestamp (to timestamp worked right away).
/stig
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Saquib Farooq Malik | 2005-06-13 05:46:44 | the PDF documentation on postgresql.org |
| Previous Message | Halley Pacheco de Oliveira | 2005-06-12 15:50:22 | Re: PostgreSQL 7.4 and 8.0 - psql reference |