Calculate week of year when Monday is the first day of week

Database
UM
Teradata Employee

Calculate week of year when Monday is the first day of week

Hi,

I can get week of year from sys_calendar but it assumes sunday as the first day of week.

How can I calculate week of year if I consider Monday to be the first day of week

Thanks!

Tags (1)
2 REPLIES
Enthusiast

Re: Calculate week of year when Monday is the first day of week

Hi,

Below SQl will help you to get week of year for week starting on monday.

SEL calendar_date, (day_of_year - (day_of_calendar -1) mod 7 + 6) / 7 as week_of_year

FROM sys_calendar.calendar

where year_of_calendar=2013

HTH

Harpreet

Enthusiast

Re: Calculate week of year when Monday is the first day of week

Hello everyone,

I have a slightly different requirement. Can someone please help? I need to get the week of the year from a date, but 1st of Jan being the 1st week. (no matter what day it falls on). How can I get this in Teradata sql?

For eg. 6 Jan 2013 is week 2.

Thank you so much.

San