Search code examples
sqloracle-databasetimefilterresponsys

How I filter SQL using curdate? (example: registers that column "created_date" are more than 180 ago) (responsys - oracle)


I need to filter my list based on date time.

Example: "people who purchased 180 days ago"

However I need that the comparison be with actual date (system date), so that I don't have to filter manually every day.


Solution

  • Subtract 180 from (truncated?) SYSDATE:

    select whatever
    from your_table
    where date_column < trunc(sysdate) - 180;
    

    Why truncate? Becuase sysdate function returns both date and time, so - you'd probably want to "remove" the time component.