1
Hi Sushant,
SELECT * FROM table
WHERE TO_DATE(END_DATE, 'DD/MM/YYYY') BETWEEN TO_DATE('01/12/2024', 'DD/MM/YYYY') AND TO_DATE('10/02/2025', 'DD/MM/YYYY');
TO_DATE(END_DATE, 'DD/MM/YYYY')
to convert VARCHAR
to DATE
Removed the extra dot (.
) from 'DD/MM/YYYY.'
To Get Last 3 Month of Data
SELECT * FROM table
WHERE TO_DATE(END_DATE, 'DD/MM/YYYY') BETWEEN TRUNC(SYSDATE) - 90 AND TRUNC(SYSDATE);
TRUNC(SYSDATE) - Used to remove the time part
TRUNC(SYSDATE) - 90 - To get the date before 90 days(3month)
If you save a date in this 02/01/2025 format, it's better to change the END_DATE column datatype to a date permanently.
You can alter the table and update the existing values.
ALTER TABLE table MODIFY END_DATE DATE;
UPDATE table SET END_DATE = TO_DATE(END_DATE, 'DD/MM/YYYY');