• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1311
  • Last Modified:

To get this year/week start date and end date from Year & Week No?

My input is Year and Week No.  How to get this year/week start date and end date?
1 Solution
year start = trunc(to_date(in_year,'yyyy'),'yyyy')
year end =  add_months(trunc(to_date(in_year,'yyyy'),'yyyy'),12)-1

week start/week end - this is tricky,  what do you consider the start of a week?

if weeks count from day 1 of the year, then try this...

week start = trunc(to_date(in_year,'yyyy'),'yyyy') + (7 * (in_week - 1))
week end =  trunc(to_date(in_year,'yyyy'),'yyyy') + (7 * (in_week - 1)) + 6

if weeks count from the first Monday of the week (ISO weeks)

week start = next_day(trunc(to_date(in_year,'yyyy'),'yyyy') -1,'Mon') + (7 * (in_week - 1))
week end = next_day(trunc(to_date(in_year,'yyyy'),'yyyy') -1,'Mon') + (7 * (in_week - 1)) + 6

if weeks count from some other rule, post what you're using and I'll try to figure out how to represent it
sboscoiAuthor Commented:
Brilliant.  Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now