By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,585 Members | 2,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,585 IT Pros & Developers. It's quick & easy.

How to get timestamp to output in format?

P: 1
I have a timestamp that is outputting incorrectly, as 28OCT2006:14:43:46.000000 instead of 2006-10-28-14.43.46. I have tried converting the timestamp to a char in the sql CHAR(A.CMS_RSPN_TS). But started receiving the following errors:
ERROR: Function CHAR requires a character expression as argument 1.
ERROR: Function CHAR requires a numeric expression as argument 2.

I have also tried the following and received the same error:
CHAR(A.CMS_RSPN_TS, 'YYYY-MM-DD HH24:MI:SS') AS CMS_TS
CHAR(A.CMS_RSPN_TS, USA)
CHAR(A.CMS_RSPN_TS, 26)



Can anyone help me with this, or have any ideas?
Oct 4 '07 #1
Share this Question
Share on Google+
2 Replies


docdiesel
Expert 100+
P: 297
Hi,

char() is only valid when used with DATE or TIME columns. It's not applicable to TIMESTAMP. You may use the date() and time() functions to first extract these values and then concatenate them as char()'s.

Regards, Bernd
Oct 7 '07 #2

docdiesel
Expert 100+
P: 297
Hi again,

although char() won't work, there's a to_char() function for converting timestamps. Try the following:

Expand|Select|Wrap|Line Numbers
  1. select
  2.   to_char(A.CMS_RSPN_TS, 'YYYY-MM-DD HH24:MI:SS')
  3. from
  4.   my.table
Regards, Bernd
Oct 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.