pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jack Zhu <jzhu@netcom-sys.com>
To: pgsql-admin@postgresql.org
Subject: to_char function for 'timestamp' and 'datetime' type?!!
Date: Thu, 13 Apr 2000 12:47:59 -0400
Message-ID: <38F5FA3E.AD140DDA@netcom-sys.com> (raw)

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
attributes.'

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
above.
'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
error?

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

Thanks!!!

Jack




Message-ID: <38F5FA3E.AD140DDA@netcom-sys.com>
Permalink:  ../38F5FA3E.AD140DDA@netcom-sys.com/
Also on:    postgresql.org/message-id/38F5FA3E.AD140DDA@netcom-sys.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: jzhu@netcom-sys.com
  Subject: Re: to_char function for 'timestamp' and 'datetime' type?!!
  In-Reply-To: <38F5FA3E.AD140DDA@netcom-sys.com>
  References: <38F5FA3E.AD140DDA@netcom-sys.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox