Skip to content
Advertisement

How to insert a timestamp in Oracle?

I have an Oracle DB with a timestamp field in it. What is the correct SQL code to insert a timestamp into this field?

Advertisement

Answer

insert
into tablename (timestamp_value)
values (TO_TIMESTAMP(:ts_val, 'YYYY-MM-DD HH24:MI:SS'));

if you want the current time stamp to be inserted then:

insert
into tablename (timestamp_value)
values (CURRENT_TIMESTAMP);
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement