To get tomorrow’s date as a datetime in Python, the easiest way is to use the Python timedelta() function from the datetime module.

from datetime import timedelta, datetime

tomorrow_datetime = datetime.now() + timedelta(days=1)

print(datetime.now())
print(tomorrow_datetime)

#Output:
2022-05-05 16:26:40.727149
2022-05-06 16:26:40.727149

When working with data in Python, many times we are working with dates. Being able to manipulate and change dates easily is very important for efficient processing.

One such change is to be able to get tomorrow’s date from today’s date.

With Python, we can easily get tomorrow’s date from the current date with the help of the datetime module.

To get tomorrow’s date, we need to add 1 day from today’s date in Python. To do so, we can use the timedelta() function from the datetime module.

Below is code that shows you how to add 1 day from now to get tomorrow as a datetime in Python.

from datetime import timedelta, datetime

tomorrow_datetime = datetime.now() + timedelta(days=1)

print(datetime.now())
print(tomorrow_datetime)

#Output:
2022-05-05 16:26:40.727149
2022-05-06 16:26:40.727149

Subtracting One Day to Get Yesterday’s Date Using Python

We can easily get yesterday’s date using the Python datetime module. To get yesterday’s date, we just need to subtract 1 day using the timedelta() function.

Below is the Python code which will allow you to get yesterday’s date.

from datetime import timedelta, date

yesterday_datetime = datetime.now() - timedelta(days=1)

print(datetime.now())
print(yesterday_datetime)

#Output:
2022-05-05 16:26:40.727149
2022-05-04 16:26:40.727149

How to Get Tomorrow’s Date With pandas in Python

If you are using the Python pandas module, we can get the date of tomorrow easily.

With pandas, to add days to a date, we use the DateOffset() function.

Below is an example of how to use pandas to get tomorrow as a datetime in Python.

import pandas as pd

tomorrow_datetime = pd.datetime.now() + pd.DateOffset(days=1)

Hopefully this article has been beneficial for you to learn how to get tomorrow as a datetime variable using Python.

Categorized in:

Python,

Last Update: February 26, 2024