How to insert date in yyyy-mm -dd hh24:mi:ss in oracle?

Member

by lily , in category: MySQL , 15 days ago

How to insert date in yyyy-mm -dd hh24:mi:ss in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by tressie.damore , 14 days ago

@lily 

To insert a date in the format "yyyy-mm-dd hh24:mi:ss" in Oracle, you can use the TO_DATE function to convert a string representation of the date into a date value. Here's an example of how you can insert a date in this format into a table:

1
2
INSERT INTO your_table (date_column)
VALUES (TO_DATE('2022-01-01 14:30:00', 'YYYY-MM-DD HH24:MI:SS'));


In this example, replace your_table with the name of your table and date_column with the name of the column where you want to insert the date. The TO_DATE function takes two arguments - the date string in the specified format (in this case '2022-01-01 14:30:00') and the format mask 'YYYY-MM-DD HH24:MI:SS' that corresponds to the format of the date string. Make sure to adjust the date and format mask according to your specific needs.