oracle add time to date 1

oracle add time to date

SELECT sysdate + 1 FROM dual; 				-- Tomorrow    12/01/2021 14:27:27
SELECT trunc(sysdate) + 1 FROM dual; 		-- Tomorrow    12/01/2021 00:00:00
SELECT sysdate + 1 / 24 FROM dual;					-- 1 hour ahead
SELECT sysdate + 1 / 24 / 60 FROM dual;				-- 1 minute ahead
SELECT add_months(trunc(sysdate), 1) FROM dual;   	-- 1 month ahead (no time)
SELECT trunc(sysdate) + 30 FROM dual;				-- 30 days ahead (no time)
SELECT add_months(trunc(sysdate), +12*2) FROM dual;	-- 2 years ahead (no time)

Here is what the above code is Doing:
1. sysdate is the current date and time.
2. trunc(sysdate) is the current date with the time portion removed.
3. trunc(sysdate) + 1 is the current date plus one day.
4. add_months(trunc(sysdate), 1) is the current date plus one month.
5. trunc(sysdate) + 30 is the current date plus 30 days.
6. add_months(trunc(sysdate), +12*2) is the current date plus two years.

Similar Posts