public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Glaesemann <[email protected]>
To: stig erikson <[email protected]>
Cc: [email protected]
Subject: Re: type casting reference?
Date: Sat, 18 Jun 2005 13:55:07 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>


On Jun 13, 2005, at 4:39 AM, 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"

Are you looking for the timestamp expressed as seconds from the Unix  
epoch? If so, look at extract(epoch from expiretime).

http://www.postgresql.org/docs/7.4/interactive/functions- 
datetime.html#FUNCTIONS-DATETIME-EXTRACT


Michael Glaesemann
grzm myrealbox com





view thread (3+ messages)

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], [email protected]
  Subject: Re: type casting reference?
  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