Search code examples
datetimeteradatacase-statementteradata-sql-assistantteradatasql

how to write datetime <= (minus some days) in teradata case statement


I have to write an sql query where I need to extract data for 30 days minus few days,

something like this, datetime <= -5 days

what is the best possible way I can write in teradata?

Thanks in advance:)


Solution

  • Exactly 5 days based on a timestamp, e.g. 2021-09-24 13:42 -> 2021-09-19 13:42

     where timestamp_column <= current_timestamp - interval '5' day
    

    Full days starting at midnight:

     where timestamp_column <= current_date - 5