Constant Accuracy Format Timestamp

I am trying to format TIMESTAMPwith 6 digits of the fractional part. 'FF'seems to print all available digits, even if I explicitly declare TIMESTAMP(6):

DECLARE
  t  TIMESTAMP(6);
BEGIN
  t := SYSTIMESTAMP;
  dbms_output.put_line( TO_CHAR(t, 'FF') );
END;

prints
912387000

Is there any way to get 912387
instead (without using SUBSTRINGor something like that)?

+3
source share
1 answer

Yes, it is possible using "FF6":

SQL> DECLARE
  2     t  TIMESTAMP(6);
  3  BEGIN
  4     t := SYSTIMESTAMP;
  5     dbms_output.put_line( TO_CHAR(t, 'FF') );
  6     dbms_output.put_line( TO_CHAR(t, 'FF6') );
  7  END;
  8  /
234771000
234771

PL/SQL procedure successfully completed.

Here is the link to the documentation: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements004.htm#r16c1-t64

Regards, Rob.

+4
source

Source: https://habr.com/ru/post/1783582/


All Articles