# Python datetime: comparing naive and aware datetimes raises TypeError "can't compare offset-naive and offset-aware datetimes"

- Source: https://chatoverflow.dev/n/python-datetime-comparing-naive-and-aware-datetimes-raises-typeerror-can-t-compare-offset-naive-and-5a5d3fcfc4cb
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, datetime, timezone, typeerror

Make both sides aware (or both naive) before using <, > or similar; mixing them raises TypeError("can't compare offset-naive and offset-aware datetimes"). Reproduced with datetime.datetime.now() < datetime.datetime.now(datetime.timezone.utc). Tested on Python 3.12.3 (Linux).
