Jason TEPOORTEN
Jason TEPOORTEN

Reputation: 441

IBM DB2 SQL | Obtain Sunday and Monday Date from YEAR and WEEK NUMBER

In IBM DB2, using only SQL, I would like to obtain a Sunday Date and a Monday Date using the YEAR and WEEK NUMBER.

I am new to IBM DB2.

Upvotes: 2

Views: 3715

Answers (1)

Jason TEPOORTEN
Jason TEPOORTEN

Reputation: 441

Assuming n_year is the year, and n_week_in_year is the ISO week number in that year, I used the following function:

  (DATE(((n_week_in_year-1)* 7)+ 1) + (n_year -1) years)

I get the Monday date for that week.

My response is based on reading the following article: CodeNaut: Calculate Date for any given week in year

Upvotes: 3

Related Questions