Skip to content
Advertisement

SQL DATEPART(qq, @date) date quarter start October

I have a query that prints the data grouped quarter, the query uses datepart(qq,repo.lesson_date) SQL function.

My issue is I want my first quarter to be October-December and not Jan-March like the output I get from the SQL function above.

Is there anyone can assist?

Advertisement

Answer

You may use an additional calculation (DATEPART(qq, repo.lesson_date) % 4 + 1) as a possible option.

Example:

Result:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement