How to get last week using Teradata Date Functions?

Database
N/A

How to get last week using Teradata Date Functions?

Hi:

I am new to Teradata. I'd like to get last week using Teradata Date functions? In SQL Server, I can use dateadd(), then datepart(). What function can I use to achieve this?

Thanks very much.

Lilly
1 REPLY
Enthusiast

Re: How to get last week using Teradata Date Functions?

You can use the Current_Date function to get today's date, then just add or subtract days from it:

select current_date
, current_date - 7 as last_week
;

But, if you need to get a particular day from last week (say Monday), then you would want to use the sys_calendar.calendar table:

select calendar_date
from sys_calendar.calendar
where calendar_date between current_date - 14 and current_date -7
and day_of_week = 2