Skip to main content
Practice

Automatically Calculating Project Deadline D-DAY

Below is a code example that shows how to automatically calculate the Deadline D-DAY for a project on a PowerPoint slide.

Calculate Project Deadline D-DAY
# Add "D-DAY" header to the first row
data[0].append("D-DAY")

# Store today's date in the today variable
today = datetime.today()

# Calculate remaining days for each row in the data
for row in data[1:]:
# Extract start date
start_date = datetime.strptime(row[2], "%Y-%m-%d")

# Extract end date
end_date = datetime.strptime(row[3], "%Y-%m-%d")

# Calculate remaining days
remaining_days = (end_date - today).days

# Add remaining days to the row
row.append(remaining_days)

In Python, you can fetch today's date using the today() method from the datetime module.

Subsequently, use the strptime method to extract the start and end dates for each project, and calculate the remaining days to add to the data.

By automating the calculation of the project's deadline D-DAY this way, you can ensure that the remaining days are automatically reflected when converting Excel data to PowerPoint slides.

In the next Chapter, we will explore how to practically apply web scraping with real-life examples.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.