how to extract only mondays in 2007

Analytics
Enthusiast

how to extract only mondays in 2007

Needs extract only mondays in 2007.

how can i achevie using Teradata SQL

Thanks
Chinna
2 REPLIES
Enthusiast

Re: how to extract only mondays in 2007

This query will give you all mondays in 2007

SELECT CALENDAR_DATE FROM SYS_CALENDAR.CALENDAR WHERE DAY_OF_WEEK = 2 AND YEAR_OF_CALENDAR = 2007;

So if you want to pick records from some other table (Say T1) for the dates which are mondays of 2007, then join with the calendar table.

ie

SELECT T1.*
FROM T1, SYS_CALENDAR.CALENDAR C
WHERE T1.TRANS_DATE = C.CALENDAR_DATE
AND C.DAY_OF_WEEK = 2 AND C.YEAR_OF_CALENDAR = 2007;

will fetch you all records from T1 for transactions that occured on mondays in 2007.
Enthusiast

Re: how to extract only mondays in 2007

Chinna,

Your question is very vague.
Do you have a table which has a date column and do you want to extract Mondays from those values
or
in general from calendar view?

Yet I guess this select will help you achieve if you change it according to your needs.

The following SQL extracts all Mondays in the date range mentioned in the where clause.

select * from sys_calendar.calendar where day_of_week=2 and calendar_date between date -77 and date
order by 1;

Also check this URL when you have time.
http://www.teradataforum.com/attachments/a040409b.doc

Hope this serves your question.