When building financial-type apps, there may be a need to work with UK tax weeks. This post describes how UK tax weeks work, and presents some formula that can help us with this task.
How do UK tax weeks and numbers work?
The HMRC site best describes how UK tax weeks and numbers work.
Income Tax weeks (tax weeks) are periods of 7 days which follow on from each other starting on 6 April each year. The first tax week is 6 April to 12 April inclusive, the second tax week is 13 April to 19 April inclusive, and so on.
The odd day or days at the end of the last complete tax week in the year, (5 April or in leap years, 4 April and 5 April) are treated as a whole tax week, which is tax week 53.
Income Tax months (tax months)
Income Tax months are periods following on from each other in an Income Tax year. They start on the sixth of one month and finish on the fifth of the following month. The first Income Tax month is 6 April to 5 May inclusive, the second Income Tax month is 6 May to 5 June inclusive, and so on.
An easy way to visualise the above is through a tax calendar, such as the one from Sage shown below.
How to generate a list of the start and end dates for UK tax weeks
Effectively, UK tax weeks always start on the 6th April. Week 2 starts 7 days after 6th April, and so on until the 5th April for the following year.
Therefore, we can generate the start and end dates for the tax weeks in a year by creating a sequence of 53 sequential numbers. We iterate through the sequence with ForAll, and calculate the start and end dates based on a calculation of multiplying the sequence number by 7.
Here is the formula to create a list of UK tax weeks for the financial year 2022.
startDate: Date(2022, 4, 6)
(Value - 1) * 7
(Value * 7) - 1
DateAdd(startDate, 1, Years),
The above formula collects the tax weeks into a collection called colTax. Here's how the result looks when we display the result in a data table.
An important point is week 53. This will contain 1 or 2 days, depending on whether the week is a leap year. Our calculation takes account of this by using the Min function to ensure that the final end date can never be greater than the start date (6th April) plus 1 year.
To verify that the result is correct, we can sort the data table in descending sequence and we can see that the end date for week 53 correctly ends on 5th April.
How to get the UK tax week number for an input date (based on a specific tax year)
Another common requirement is to take an input date and calculate the UK tax week number corresponding to the input date.
Since UK tax weeks always begin on 6th April, we can make this calculation by working out the number of days that have elapsed since 6th April. We then work out the number of weeks by dividing by 7 and that will give us the tax week number. Since the first week is week 1, we must round up to the next highest number.
The formula to derive the week number for the tax year 2022-2023 looks like this:
In this example, the input date comes from a date picker control called dpTaxInput. The screenshot below shows how the formula returns the expected result for the input date 4th January 2023 (week 40).
How to get the UK tax week number from an input date (generic formula)
The initial formula above highlights the principle of how to calculate the tax week for an input date. However, the formula is hard-coded to use 5th April 2022 (ie - the UK tax year 2022-2023).
A more generic formula that avoids the need to specify the tax year looks like this. This includes the conditional logic that's required to calculate the base tax year. For example, an input date of 7th March 2023 will correspond to the tax year starting 2022 because the input date is less than 6th April of the input year.
If(Month(inputDate) >=4 && Day(inputDate) >5,
This post demonstrated formula to calculate the UK tax week for a given input date and to generate a list of the start and end dates for tax weeks in a year, These types of calculations can be very useful when building financial type apps.