Getting The Start and End Of The Next Year In C# & .NET
[C#, .NET, Dates]
The previous post, “Getting The Start and End Of The Previous Year In C# & .NET”, discussed how to get the start and end dates of the previous year given a DateOnly.
In this post, we will look at how to compute the following:
- Start of the next year
- End of the next year
Start of the next year
To get the start of the next year, we can do the following:
- Get the start of the current year
- Get the year
- Increment the year by
1 - Create a new
DateOnlywith these parameters
Thus, given a date, 1 July 2025
- Start of the current year is 1 Jan 2025
- The year is
2025 - Increment to
2026 - Create a new
DateOnly
The code is as follows:
/// <summary>
/// Returns the start of the next year
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public static DateOnly GetStartOfNextYear(this DateOnly date)
{
// Create a new dateonly using the current year plus one, first day, and first month (Jan)
return new DateOnly(date.Year + 1, 1, 1);
}
We next create some tests to make sure it works:
[Trait("Year", "Start")]
[Theory]
[InlineData(2025, 4, 2, 2026, 1, 1)]
[InlineData(2025, 12, 31, 2026, 1, 1)]
public void StartOfNextYearTests(int testYear, int testMonth, int testDay, int actualYear, int actualMonth,
int actualDay)
{
var testDate = new DateOnly(testYear, testMonth, testDay);
testDate.GetStartOfNextYear().Should().Be(new DateOnly(actualYear, actualMonth, actualDay));
}
End of the next year
To get the end of the next year, we leverage some of the work that we have done earlier.
- Get the start of the current year, using the method we have just written,
GetStartOfNextYear() - With that
DateOnly, get the end of that (current) year, using theGetEndOfCurrentYear()method we wrote here.
The code looks like this:
/// <summary>
/// Return the end of the next year
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public static DateOnly GetEndOfNextYear(this DateOnly date)
{
// Get the start of the next year
var startOfNextYear = date.GetStartOfNextYear();
// Return the end of that year
return startOfNextYear.GetEndOfCurrentYear();
}
We then create some tests for the same:
[Trait("Year", "End")]
[Theory]
[InlineData(2025, 4, 2, 2026, 12, 31)]
[InlineData(2025, 12, 31, 2026, 12, 31)]
public void EndOfNextYearTests(int testYear, int testMonth, int testDay, int actualYear, int actualMonth,
int actualDay)
{
var testDate = new DateOnly(testYear, testMonth, testDay);
testDate.GetEndOfNextYear().Should().Be(new DateOnly(actualYear, actualMonth, actualDay));
}
If we run our tests, they should pass.

TLDR
In this post, we have written methods to compute:
- First day of the next year
- Last day of the next year
The code is in my GitHub.
Happy hacking!