# Calculate Sunday in given week.

Hi Experts

Need your assistance please.  I have a field "date" in a report that I then need to calculate the Sunday date of the week that the date falls.
The date field is actually formatted as a date (mm/dd/yyyy) if that is relevant.

Andy
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
0
Author Commented:
Maybe I am missing something but your solution is giving me the "day name" for my date.  I don't need this but rather need the date of the last day of that week (Sunday).  The results should always be a Sunday.
0
Commented:
Try this formula based on currentdate

If you are using a database field then change CurrentDate to the field

mlmcc
0
Commented:
If DayOfWeek({@Today}) = 2 Then
Else If DayOfWeek({@Today}) = 3 Then
Else If DayOfWeek({@Today}) = 4 Then
Else If DayOfWeek({@Today}) = 5 Then
Else If DayOfWeek({@Today}) = 6 Then
Else If DayOfWeek({@Today}) = 7 Then
Else If DayOfWeek({@Today}) = 1 Then
0
Author Commented:
mlmcc---getting error message--"a number is required"

0
Author Commented:
BlueYonder

Your solution is giving me the Sunday before the date.  What I need is Sunday as the last day of the week.  If my date is 12/13/2013 which is a Friday I need 12/15/13 which would be the last day of the week (Sunday).
0
Commented:
I assume it is on the one using the datefield.  Missed the closing }

mlmcc
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Thanks so much for your elegant solution.  It still was using Sunday as the 1 day of the week so for example if I had a date of 12/13/13 (Friday) it was returning 12/8/13 (Sunday) where I wanted 12/15/13 (Sunday).  This would make Sunday the last day of the week.  I just added 7 to your formula and it gave me the proper date required.