General
Enthusiast

## To get the Previous year week's sunday date from the current date.

Hi,

Could anyone help me in getting the previous year week's sunday date from the current date.

Eg:  If I pass today's date as 9/15/2016

It should return 9/13/2015 i.e sunday date from previous year.

Thanks!!

Tags (1)

Accepted Solutions
Junior Supporter

## Re: To get the Previous year week's sunday date from the current date.

Hi

I do not know whether there is any other better way. but below query should work.

select calendar_date - (case day_of_week when 1 then 0
when 2 then 1
when 3 then 2
when 4 then 3
when 5 then 4
when 6 then 5
when 7 then 6
end ) as sunday_of_week
from Sys_calendar.calendar
where calendar_date = add_months(cast('2016-09-15' as date), - 12)

1 ACCEPTED SOLUTION
4 REPLIES
Junior Supporter

## Re: To get the Previous year week's sunday date from the current date.

Hi

I do not know whether there is any other better way. but below query should work.

select calendar_date - (case day_of_week when 1 then 0
when 2 then 1
when 3 then 2
when 4 then 3
when 5 then 4
when 6 then 5
when 7 then 6
end ) as sunday_of_week
from Sys_calendar.calendar
where calendar_date = add_months(cast('2016-09-15' as date), - 12)

Junior Contributor

## Re: To get the Previous year week's sunday date from the current date.

Try this simple logic: subtract 52 weeks from today (current_date - 52*7) and then apply the td_sunday function:

`td_sunday(current_date-52*7)`

Junior Supporter

## Re: To get the Previous year week's sunday date from the current date.

Td_sunday function is awesome. Simple and nice if you have Td 14.10 or greater. Thank you Dnoeth for letting us know this new function.

Enthusiast

## Re: To get the Previous year week's sunday date from the current date.

Hi,

It will be helpful if you share the query by using the logic using td_sunday  function.

Thanks!!