Skip to main content

How to Get the Date from a datetime in Python with .date()

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

A datetime holds a date and a time, such as 2026-12-01 03:54:45. Often you only want the day: to name a file, to compare days, or to ask an API for one day's data. The .date() method gives you that part. This guide uses it on Python 3.15.2.

Syntax​

Syntax
<datetime>.date()
PartWhat it means
<datetime>Any datetime object, such as the one datetime.now(UTC) returns
.date()Returns a new date object with only the year, month and day. The datetime itself doesn't change

Python's datetime documentation describes it in one line: "Return date object with same year, month and day."

The Example​

The script takes the current moment in UTC, keeps only its date, and prints both, plus the type of the result.

Prerequisites​

  • uv and Python 3. This guide uses uv 0.13.10 with Python 3.15.2, in a project made with uv init.

Step 1: Write the Script​

date_part.py
from datetime import UTC, datetime

now = datetime.now(UTC)
today = now.date()

print(now)
print(today)
print(type(today).__name__)

The date_part.py script in a macOS-style code window: it imports UTC and datetime, stores datetime.now(UTC) in now, stores now.date() in today, and prints now, today and the name of today's type.

UTC is Python's name for the UTC time zone, so now is the current time in UTC rather than in your computer's time zone.

Step 2: Run It​

Terminal
uv run python date_part.py
Output
2026-12-01 03:54:45.803992+00:00
2026-12-01
date

The terminal after uv run python date_part.py: the full datetime 2026-12-01 03:54:45.803992+00:00, then the date 2026-12-01, then the type name date.

The first line is the whole datetime, with its time and its +00:00 offset. The second is the same moment cut down to its date. The third shows that .date() returned a date, a different type from datetime. Your first two lines show the moment you run it. The command works unchanged in PowerShell.

Common Mistakes​

MistakeWhat happensDo this instead
Leaving out the brackets: now.datePython prints the method itself, <built-in method date of datetime.datetime object at 0x103547b10>, instead of a dateCall it: now.date()
Using date.today() when you need UTCdate.today() returns "the current local date", in Python's words: your computer's time zone, which can be a different day from UTC around midnightTake the date from a UTC datetime: datetime.now(UTC).date()

Troubleshooting​

SymptomLikely causeFix
The output says <built-in method date of ...>The brackets after date are missingAdd ()
The date is one day off from what a server or API showsOne side uses local time and the other UTCUse UTC on both sides

FAQ​

Does .date() change the original datetime?​

No. It returns a new date and leaves now as it was: the script printed the full now after calling .date().

How do I get the time part instead?​

Use .time(). The same page lists it right after .date().

Conclusion​

datetime.now(UTC).date() turned 2026-12-01 03:54:45.803992+00:00 into 2026-12-01, a date object with no time and no time zone. Use it whenever only the day matters.

Additional Resources​