Week dates question

Hi,
Given a week of year number, how to find the first day and the last day of this week
What i’ve tried is :
FirstDayOfWeek = ( (FirstDayofYear + (WeekNumber * 7) ) - 7) + 1
LastDayofWeek = (FirstDayOfWeek + 7) -1

This code returns a wrong TrueDate +7

What’s is wrong here and what’s your approach to this simple deal ?

Hi jwabet

In my case i use something like this to know the day of week. I think you can adjust that every time is 0 or 6 is Sunday or Saturday or any day of the week.

LocDay = LocDate % 7
CASE LocDay
  OF 0
    STOP('Today day is Sunday')
  OF 1
    STOP('Today day is Monday')
  OF 2
    STOP('Today day is Tuesday')
  OF 3
    STOP('Today day is Wednesday')
  OF 4
    STOP('Today day is Thursday')
  OF 5
    STOP('Today day is Friday')
  OF 6
    STOP('Today day is Saturday')
END!Case

Thank you urayoan but your solution is to find the day name
i’m looking for the week (this week is number 20) first and last day dates.

I’d change things a little for simplicity

LastDayOfWeek = ( (FirstDayofYear + (WeekNumber * 7) ) -1
FirstDayofWeek = LastDayOfWeek - 6

Should work

Sean,
What actually works for me is to modify your piece of code by supressing the last (-1) :
LastDayOfWeek = ( (FirstDayofYear + (WeekNumber * 7) ) ===> Sunday
FirstDayofWeek = LastDayOfWeek - 6 ===> Monday
Thank you.