A TIMESTAMP is a binary data format consisting of 7-20 bytes (century, year-of-century, month, day, hour, minute, second, up to 6 bytes for fractional seconds and up to 7 bytes for time zone information); it does NOT have a format.
Why am I seeing the TIMESTAMP with a format?
You are seeing it with a format because whatever user interface you are using to access the database has decided that it is more useful to display the binary information as a formatted string rather than returning the raw byte values to you.
Typically, for SQL/Plus and SQL Developer, this is managed by the NLS_TIMESTAMP_FORMAT session parameter. Other user interfaces will have different mechanisms by which they manage the default format of dates and timestamps.
If you want to change the default for SQL/Plus (and SQl Developer) then you can use:
ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF9';
(Or whatever format you would like.)
How can I format the TIMESTAMP value?
If you then want to display the timestamp with a format (remember, a TIMESTAMP is not stored with any format) then you want to use TO_CHAR to convert it to a string where it can have a format.
If you want to format the TIMESTAMP as a YYYY-MM-DD HH24:MI:SS.FF3 string then use:
SELECT TO_CHAR( your_timestamp_column, 'YYYY-MM-DD HH24:MI:SS.FF3' )
FROM your_table
How can I convert a formatted string back to a TIMESTAMP?
From your comment:
I loaded the oracle data into a different SQL table where date format was varchar and data got loaded as '01-APR-21 12.02.00.496677000 AM'
Use TO_TIMESTAMP:
SELECT TO_TIMESTAMP( your_string_column, 'DD-MON-RR HH12:MI:SS.FF9 AM' )
FROM your_table
(Note: that this will convert your string to a binary TIMESTAMP and then whatever user interface you are using will use its rules on how to display it; and if the default format it is using is DD-MON-RR HH12:MI:SS.FF9 AM then the query above will look like it has done nothing; it has, the UI is just implicitly converting it back to a string to display it.)
nls_timestamp_format. You could change that for the current session but it seems very weird that you care about the display format of a timestamp if you're moving it to a different database. Any ETL tool should just move the data from atimestampcolumn to adatetimewithout worrying about what format the current session would use if it wanted to do an implicit conversion of thetimestampto avarchar2. - Justin Caveto_char()with the format you require for each date/timestamp column. But we need to know what you are doing to be able to help you. - Alex Pooletimestampfrom an Oracle database and move it to adatetimein SQL Server without requiring an implicit conversion of thetimestampto avarchar2. You could, of course, do an explicitto_charon thetimestampto convert it to a string in whatever format you want. But, again, it seems unlikely that this step would be necessary. - Justin Cavetimestampin Oracle todatetimein SQL Server shouldn't care about character format output; the ETL tool should be able to perform a direct conversion from one datatype to the other. - pmdba