Sarshad
Sarshad

Reputation: 29

How to use Week() in db2 with thursday as the starting day of the week instead on Monday or Sunday

I am selecting some data grouped by week but I would like to select data from the table week wise with week starting with thursday. I am currently working with Week(my_date) but it starts week with sunday and week_iso(my_date) starts the week with monday. But I need to start the week from thursday.

Upvotes: 0

Views: 829

Answers (1)

data_henrik
data_henrik

Reputation: 17156

You would need to use date arithmetics. Just add or subtract the difference of days to your start date.

week(my_date+4 days)

or

week_iso(my_date - 3 days)

The above are just examples. You need to adjust it depending on where you set your baseline, i.e., what is week 1.

Upvotes: 1

Related Questions