How to add date and time in oracle?

by filiberto , in category: MySQL , 9 months ago

How to add date and time in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by gilbert , 9 months ago

@filiberto 

In Oracle, you can add date and time using the TO_DATE function to convert a date or a timestamp into a specific format.


Here is an example of how you can add date and time in Oracle:

1
2
SELECT TO_DATE('2022-11-30 10:30:00', 'YYYY-MM-DD HH24:MI:SS') + INTERVAL '1' HOUR
FROM dual;


This query will add 1 hour to the specified date and time ('2022-11-30 10:30:00') and return the updated date and time.


You can also use the INTERVAL keyword with different units (e.g. HOUR, MINUTE, SECOND) to add/subtract specific time intervals to a date or timestamp in Oracle.