public inbox for [email protected]
help / color / mirror / Atom feedFrom: stig erikson <[email protected]>
To: [email protected]
Subject: Re: type casting reference? SOLVED
Date: Wed, 15 Jun 2005 21:03:18 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
stig erikson wrote:
> 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
solved my problem this way:
UPDATE table
SET expiretime= cast( ('now'::text)::timestamp+'30 minutes'::interval AS timestamp)
WHERE sessionID='0';
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: type casting reference? SOLVED
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox