Skip site navigation (1) Skip section navigation (2)

to_char function for 'timestamp' and 'datetime' type?!!

From: Jack Zhu <jzhu(at)netcom-sys(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: to_char function for 'timestamp' and 'datetime' type?!!
Date: 2000-04-13 16:47:59
Message-ID: (view raw or whole thread)
Lists: pgsql-admin
Hi, all:

PostgreSQL for Linux 6.5.3.

Our app need to use 'to_char' function on one 'datetime' column, I use
as following:

'select to_char(col_name,'MM/DD/YYYY HH:MI:SS') from tab_name where
...... ;'

The error is  'No such function 'to_char' with the specified

Now I try the 'timestamp' type, 'cause our app has to show both date and
time in one single columns.

'create table try (try timestamp);' createing is OK.
'insert into try values ('04/13/2000 00:00:00');' inserting is also Ok.
'select to_char(try, 'MM/DD/YYYY HH:MI:SS') from try;' Same error as
'select to_char(timestamp 'try', 'MM/DD/YYYY HH:MI:SS') from try;' the
error is 'Bad abstime external representation 'try'.

I have no idea what to do now! According to the docs, 'to_char' function
should work on 'timestamp' data type. But I cannot make it work, Syntax

The other thing, 'cause we cannot create index on 'timestamp' columns.
We may have to stick with 'datetime' type. But how can we use 'to_char'
function on 'datetime' data type?

Could anyone help us out? Kind of emergency



pgsql-admin by date

Next:From: Margarita BarvinokDate: 2000-04-13 17:26:22
Subject: Error in Compilation
Previous:From: Duncan MorganDate: 2000-04-13 16:16:20
Subject: Info

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group