Thread: datetime

datetime

From
"Pramod R. Bhagwat"
Date:
Hi,
i have a table Test with following fields
Id int
Expires int
The below query works perfectly fine on PostgreSQL version 7.0

select TO_CHAR(TIMESTAMP(datetime(Expires)), 'DD-MM-YYYY HH:MI AM') from
Test;

 But it doesn't work on PostgreSQL version 7.2 On PostgreSQL version 7.2
i get following error
ERROR:  parser: parse error at or near "datetime"
Please inform me what changes i have to make.
Regards,
pramod


Re: datetime

From
Jean-Christian Imbeault
Date:
Pramod R. Bhagwat wrote:
 >
 > Hi JC,
 > i tried above but it doesn't work i got following error
 > ERROR:  Cannot cast type 'integer' to 'timestamp with time zone'

Oops ... forgot you can't force an int to be a timestamp.

Don't know the answer to your question. But to help you in the long run
how about convertinf your column definition from int to timnestamp (if
it really is a timestamp it should be of that type and not int).

Jc



Re: datetime

From
"Pramod R. Bhagwat"
Date:
> try:
>
> select TO_CHAR(Expires::timestamp, 'DD-MM-YYYY HH:MI AM') from Test;
>

Hi JC,
 i changed previous query to the following
select TO_CHAR(datetime(expires), 'DD-MM-YYYY HH:MI AM') from Test;
it works fine.
Regards,
pramod