How to convert timestamp to yyyy-mm-dd hh24:mi:ss format in oracle?

Member

by brandy , in category: MySQL , a year ago

How to convert timestamp to yyyy-mm-dd hh24:mi:ss format in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by larissa , a year ago

@brandy 

You can convert a timestamp to the "yyyy-mm-dd hh24:mi:ss" format in Oracle using the TO_CHAR function. Here is an example query:

1
2
SELECT TO_CHAR(timestamp_column, 'yyyy-mm-dd hh24:mi:ss') AS formatted_timestamp
FROM your_table_name;


In this query:

  • Replace timestamp_column with the name of the column in your table that contains the timestamp you want to format.
  • Replace your_table_name with the name of your table.


The TO_CHAR function takes two arguments: the timestamp column you want to format and the desired format string 'yyyy-mm-dd hh24:mi:ss'. This format string specifies that the output should be in the format "yyyy-mm-dd hh24:mi:ss".


When you run this query, the timestamp values in the specified column will be converted to the "yyyy-mm-dd hh24:mi:ss" format.

Related Threads:

How to insert date in yyyy-mm -dd hh24:mi:ss in oracle?
How to convert strings to a 'mm/dd/yyyy' format in teradata?
How to convert 'dd-mm-yyyy' to 'dd-mmm-yyyy' in postgresql?
How to convert yyyy-mm-dd hh:mm:ss to hh:mm:ss in mysql?
How to add days using moment.js with format of mm/dd/yyyy?
How set the datepicker in moment.js to yyyy-mm-dd?