Search Postgresql Archives

Re: How to typecast an integer into a timestamp?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday, January 27, 2012 7:44:55 am bboett@xxxxxxx wrote:
> Hello!
> 
> again quite a stupid problem i regularly run into....
> and that i still haven't solved yet...
> 
> again i used a type timestamp to keep a track of modification time, and
> again it gets stupid and confusing.....
> 
> first of all the errors are labeled as timestamp without timezone, i only
> specified timestamp....


http://www.postgresql.org/docs/9.0/interactive/datatype-datetime.html
"
Note: The SQL standard requires that writing just timestamp be equivalent to 
timestamp without time zone, and PostgreSQL honors that behavior. (Releases 
prior to 7.3 treated it as timestamp with time zone.)
"

> 
> the data was created as a timestamp with php-mktime, but when sending to
> the database postgres complains that its an int, and when i try to
> typecast it, (with the ::timestamp appendix to the value), that its not
> possible to convert an int to a timestamp (without timezone) .....

Alter the field to be timestamp with time zone and see if that helps. FYI if you 
want to cast to timestamp with time zone, use  ::timestamptz

> 
> so as usual i would discard the timezone datatype and alter the table to
> use integer instead, but this time i am wondering, since this datatype is
> present, there's surely a way to use it properly? but how?
> 
> please enlighten me!
> 
> ciao
> Bruno

-- 
Adrian Klaver
adrian.klaver@xxxxxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux