Skip to content
Advertisement

Break periods at the end of the month

SQL Server 2017

SQL-FIDDLE-LINK

In TABLE_1 there are plan number and plan start date.

TABLE_2 contains period numbers for each plan number.

I would like to compute the corresponding period start dates:

Each period is exactly 7 days long, unless the period contains a month end. Then the period should be divided into a range before the end of the month up to and including the last day of the month and a range after the end of the month.

The Select:

This returns the start data but without the extra to consider the respective month end:

I would like an output like this:

Advertisement

Answer

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