Date Functions: Where Clause Joins

Description: Examples of using dates in WHERE Clause Joins.

SELECT SYSDATE FROM dual;
 
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
 
SELECT SYSDATE FROM dual;
 
/
 
/
 
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
 
CREATE TABLE t (
datecol DATE);
 
INSERT INTO t
(datecol)
VALUES
(SYSDATE);
 
SELECT * FROM t;
 
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
 
SELECT * FROM t;
 
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
 
SELECT * FROM t;
 
SELECT SYSDATE FROM dual;
 
SELECT * FROM t
WHERE datecol = SYSDATE;
 
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
 
SELECT * FROM t;
 
SELECT SYSDATE FROM dual;
 
SELECT TRUNC(SYSDATE) FROM dual;
 
SELECT * FROM t
WHERE TRUNC(datecol) = TRUNC(SYSDATE);
 
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.