Search Postgresql Archives

Re: Time and date functions give me headaches!!

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

 



On Mon, 2005-04-11 at 04:40, Costin Manda wrote:
>   Hello,
> 
> I have a table with columns defines as varchar that have values in format
> 'YYYY-MM-DD HH:MM:SS'.
> 
> Now, if I do a
> select timestamp '2005-10-10 10:10:10';
> I get the value just fine. I can use abstime()::integer on the result to
> find the unix timestamp. (This is the simplest way I could find, are there
> any others?)
> 
> However, when I try doing the same with the values in the table I can't
> get it to work.
> 
> select timestamp setuptime from billing; - error
> select timestamp(setuptime) from billing; - error
> select setuptime::timestamp from billing; - error (cannot cast type
> character varying to timestamp without timezone!?)
> 
> So, how can I convert this string into a timestamp, pleeease! :(

More importantly, why are you storing your timestamps as strings? 
Sotring them as timestamps is the proper way to do things.  It provides
bounds checking, and allows date maths to be done rather simply.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

[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