
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Calculate Date Six Months from Current Date using datetime in Python
Python does not have a data type for dates, but we may import the datetime module to work with dates as date objects. Calculating dates that are months apart from a given date is quite challenging due to the varying length of months in our calendar system. This article tells about how to display the current date by importing the datetime module.
There are two main methods to calculate a date six months from now in Python, which includes -
Using relativedelta() Function
The relativedelta type is intended to be applied to an existing datetime and can either indicate a period of time or replace specific elements of that datetime.
For the relativedelta class to perform month-based calculations, the dateutil package should be installed.
Example - Calculating with Current Date
The Python datetime module can be used to get the date six months from the current date. The code is shown below ?
from datetime import date from dateutil.relativedelta import relativedelta # Adding six months to the current date and returning new date # Assigning the sum to six_months_from_now six_months_from_now = date.today() + relativedelta(months=+6) print(six_months_from_now)
Following is an output of the above code ?
2025-10-17
Example - Calculating with a Specific Starting Date
Following is an alternate way of calculating the date six months from the current date using relativedelta() function ?
from datetime import date from dateutil.relativedelta import relativedelta six_months_from_now = date(2022, 1, 8) + relativedelta(months=+6) print(six_months_from_now )
Following is an output of the above code ?
2022-07-08
Example - Including Time with datetime Objects
Following is an alternate way of calculating the date six months from the current date along with the timezone using relativedelta() function ?
from datetime import datetime from dateutil.relativedelta import * six_months_from_now = datetime.now() print(f"Current date and time: {six_months_from_now}") six_months_from_now = datetime.now() + relativedelta(months=+6) print(f"Date and time 6 months from now : {six_months_from_now}")
Following is an output of the above code ?
Current date and time: 2025-04-17 15:57:48.032064 Date and time 6 months from now : 2025-10-17 15:57:48.032071
Using timedelta() Function
A class in the datetime module that represents duration is called timedelta. The duration describes the difference between two date, datetime, or time instances whereas the delta denotes the average of the difference.
Example - Simple Approximation
You can also use the timedelta() function to get the date that will occur six months from the current date as follows ?
import datetime print((datetime.date.today() + datetime.timedelta(6*365/12)).isoformat())
Following is an output of the above code ?
2025-10-16
Example - Fixed 30-Day Month Approximation
Following is an alternate way of calculating the date six months from the current date using timedelta() function ?
import datetime current_day = datetime.date.today() print (current_day) six_months_from_now = current_day + datetime.timedelta(30*6) print (six_months_from_now)
Following is an output of the above code ?
2025-04-17 2025-10-14