How to convert a timestamp to a string in Oracle?

In Oracle database, you can use the TO_CHAR function to convert TIMESTAMP data type to a string. Here is an example:

SELECT TO_CHAR(my_timestamp_column, 'YYYY-MM-DD HH24:MI:SS') AS my_timestamp_str
FROM my_table;

In this example, the column my_timestamp_column is of type TIMESTAMP. It is converted to a string using the TO_CHAR function, specifying the format for date and time (‘YYYY-MM-DD HH24:MI:SS’). Different date and time formats can be chosen for conversion as needed in practical use.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds