Files
30-seconds-of-code/snippets/days_diff.md
Isabelle Viktoria Maciohsek cbc78ee450 Bake dates into snippets
2021-06-13 19:38:10 +03:00

22 lines
421 B
Markdown

---
title: days_diff
tags: date,beginner
firstSeen: 2020-10-28T16:19:39+02:00
lastUpdated: 2020-10-28T16:19:39+02:00
---
Calculates the day difference between two dates.
- Subtract `start` from `end` and use `datetime.timedelta.days` to get the day difference.
```py
def days_diff(start, end):
return (end - start).days
```
```py
from datetime import date
days_diff(date(2020, 10, 25), date(2020, 10, 28)) # 3
```