Someone recently tried to add months to the current date in PowerShell. In this tutorial, I will explain how to add months to date in PowerShell with examples.
To add months to a date in PowerShell, you can use the AddMonths method of the DateTime object. For example, to schedule a follow-up meeting three months from today, you can use the following script:
$today = Get-Date
$followUpMeeting = $today.AddMonths(3)This script takes the current date and adds three months to it, outputting the new date.
AddMonths() method in PowerShell
The AddMonths method is a part of the DateTime object in PowerShell. This method allows you to add a specified number of months to a date. It’s particularly useful for scheduling tasks, setting reminders, or managing time-sensitive data.
Syntax
The syntax for the AddMonths method is:
$date.AddMonths(int months)Here, $date is a DateTime object, and months is an integer representing the number of months you want to add. If you want to subtract months, you can pass a negative integer.
Here is an example:
$today = Get-Date
$followUpDate = $today.AddMonths(2)
$followUpDateI executed the above PowerShell script, and you can see the output in the screenshot below:

Check out PowerShell Get-Date Minus 1 Day
PowerShell Date Add Months Examples
Now, let me show you a few real examples of using AddMonths method in PowerShell.
Example 1: Schedule a Meeting
Imagine you need to schedule a follow-up meeting three months from today. Here’s how you can do it using PowerShell.
$today = Get-Date
$followUpMeeting = $today.AddMonths(3)
Write-Output "The follow-up meeting is scheduled for $($followUpMeeting.ToString('MMMM dd, yyyy'))"This script gets the current date, adds three months to it, and then outputs the new date in a readable format. If today is September 19, 2024, the output will be:
The follow-up meeting is scheduled for December 19, 2024Here is the exact output in the screenshot below:

Read PowerShell Date Comparison
Example 2: Set a Subscription Renewal Date
Let’s say you manage subscriptions and need to set a renewal date six months from the initial subscription date. Here’s how:
$subscriptionStartDate = Get-Date -Year 2024 -Month 9 -Day 19
$renewalDate = $subscriptionStartDate.AddMonths(6)
Write-Output "The subscription renewal date is $($renewalDate.ToString('MMMM dd, yyyy'))"If the subscription started on September 19, 2024, the renewal date will be:
The subscription renewal date is March 19, 2025Here is the exact output in the screenshot below:

Read Get Date and Time in 24-Hour Format in PowerShell
Example 3: Calculate Past Dates
You can also use the AddMonths method to calculate dates in the past. For instance, if you want to find out what the date was six months ago:
$today = Get-Date
$sixMonthsAgo = $today.AddMonths(-6)
Write-Output "The date six months ago was $($sixMonthsAgo.ToString('MMMM dd, yyyy'))"If today is September 19, 2024, the output will be:
The date six months ago was March 19, 2024Example 4: Handle End-of-Month Scenarios
One thing to note is how the AddMonths method handles end-of-month scenarios. For example, adding one month to January 31 will result in February 28 or 29, depending on whether it’s a leap year.
$date = Get-Date -Year 2024 -Month 1 -Day 31
$newDate = $date.AddMonths(1)
Write-Output "One month from January 31, 2024, is $($newDate.ToString('MMMM dd, yyyy'))"For January 31, 2024, the output will be:
One month from January 31, 2024, is February 29, 2024This is because 2024 is a leap year.
Here is the exact output you can see in the screenshot below:

Conclusion
The AddMonths method in PowerShell can be used to add or subtract months. In this tutorial, I explained how to add months to date in PowerShell and also shown a few real examples of using AddMonths() method in PowerShell.
You may also like the following tutorials:
- Get Date Differences Between Two Dates in PowerShell
- PowerShell Get-Date UTC
- Sort Files by Date in PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.