Calculating financial week in SQL

sabb 1 Reputation point

I need your help in calculating financial weeks based on below rules:

  1. if there are 3 or more working days (Monday to Friday) in the last week of June then it is week 53
  2. if there less than 3 working days in the last week of June then it is week 1 in the next financial year.
    3.My calendar starts from year 2012.

I appreciate your help.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,690 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tom Phillips 17,716 Reputation points

    Create a "calendar table" and calculate this once. Then you can use it for your query.