# Parsing Dates with to_datetime

Dates read from a file are text that sorts and compares wrongly, so pd.to_datetime turns them into real dates, format= says how they were written instead of letting pandas guess, '03/04/2026' is March 4 or April 3 depending on dayfirst, errors='coerce' turns a date that can't exist into NaT for you to list, and parse_dates= does it while loading.

![Cheat sheet: Parsing Dates with to_datetime](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/7634dc035ed448fca07d7cce1d375a59.webp)

- Category: Data Analysis
- Level: Apprentice
- Tags: Date Format Code, NaT, python, to_datetime()
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/pandas-to-datetime-cheat-sheet
