datetime

Started by Pramod R. Bhagwatover 23 years ago3 messagesgeneral
Jump to latest
#1Pramod R. Bhagwat
pramod@ncoretech.com

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

#2Jean-Christian Imbeault
jc@mega-bucks.co.jp
In reply to: Pramod R. Bhagwat (#1)
Re: datetime

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

#3Pramod R. Bhagwat
pramod@ncoretech.com
In reply to: Pramod R. Bhagwat (#1)
Re: datetime

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