I am looking to return all days from the past 6 months.
Per example:
Column1 ------- 01-OCT-18 30-SEP-18 29-SEP-18 ........ 01-APR-18
@TimBiegeleisen – Your solution pointed me in the right direction, so you get the points.
@MT0 – “ADD_MONTHS” as far as I know is not used in T-SQL so the the clarification I believe was necessary. but thank you for the pointer with the updates will refrain from doing that in the future.
Advertisement
Answer
We can compare each date in Column1
against SYSDATE
, 6 months earlier, and then display the dates in the format you want using TO_CHAR
with an appropriate format mask:
SELECT TO_CHAR(Column1, 'dd/mm/yy') AS output FROM yourTable WHERE Column1 >= ADD_MONTHS(SYSDATE, -6);