Just a note on dates and midnight:
```
d1 = datetime(today.year, today.month, today.day)  # makes d1 = today at 00H00 which is yesterday midnight
```