I need to add new business wee to my dim_date actually i have week of the month that is counting every 7 days of month as the table bellow.
Date | Week of month | day_of_week |
---|---|---|
01/04/2022 | 1 | Friday |
02/04/2022 | 1 | Saturday |
03/04/2022 | 1 | Sunday |
04/04/2022 | 1 | Monday |
05/04/2022 | 1 | Tuesday |
06/04/2022 | 1 | Wednesday |
07/04/2022 | 1 | Thursday |
08/04/2022 | 2 | Friday |
09/04/2022 | 2 | Saturday |
10/04/2022 | 2 | Sunday |
But for this business week column the week should start on Monday and end at Sunday, even if the first week is only one day(when a month starts at Sunday), but if the month starts on Friday, I should consider it as the first week of the month.
Date | Week of month | day_of_week |
---|---|---|
01/04/2022 | 1 | Friday |
02/04/2022 | 1 | Saturday |
03/04/2022 | 1 | Sunday |
04/04/2022 | 2 | Monday |
05/04/2022 | 2 | Tuesday |
06/04/2022 | 2 | Wednesday |
07/04/2022 | 2 | Thursday |
08/04/2022 | 2 | Friday |
09/04/2022 | 2 | Saturday |
10/04/2022 | 2 | Sunday |
Do you have any suggestion to calculate this? Thank you
This query gets the number of the week from
2002-04-01
to2002-04-19
. The week start from monday and finishes on sunday. You can see this example:You can see the result.
You need to use
EXTRACT
function.