Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sysdate in oracle sql

SELECT sysdate - 1 FROM dual; 				-- Yesterday    12/01/2021 14:27:27
SELECT trunc(sysdate) - 1 FROM dual; 		-- Yesterday    12/01/2021 00:00:00
SELECT sysdate + INTERVAL '20' DAY FROM DUAL;		-- 20 days ahead (other way)
SELECT sysdate - 1 / 24 FROM dual;					-- 1 hour ago
SELECT sysdate - 1 / 24 / 60 FROM dual;				-- 1 minute ago
SELECT add_months(trunc(sysdate), -1) FROM dual;   	-- 1 month ago (no time)
SELECT trunc(sysdate) - 30 FROM dual;				-- 30 days ago (no time)
SELECT add_months(trunc(sysdate), -12*2) FROM dual;	-- 2 years ago (no time)

-- ⇓ Test it ⇓ (Fiddle source link)
Source by sqlfiddle.com #
 
PREVIOUS NEXT
Tagged: #sysdate #oracle #sql
ADD COMMENT
Topic
Name
1+2 =