Python datetime.date() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
datetime method

Definition

moment.date() returns a new date object with the same year, month, and day as the datetime. The hour, minute, second, microsecond, and tzinfo are dropped.

It is the usual way to compare a datetime with a date, to group timestamps by calendar day, or to print only the day. Its partners are time() for the clock part and combine() to put the two back together.

datetime.date() is an instance method of datetime.datetime: call it on an existing object with dot notation, such as moment.date(...). Import the class first, for example from datetime import datetime.

Syntax

Call it with no arguments on a datetime.

python
day = moment.date()
CallWhat it does
datetime(2024, 3, 15, 18, 45).date()Returns datetime.date(2024, 3, 15).
datetime(2024, 1, 1, 8, 0, tzinfo=timezone.utc).date()Returns datetime.date(2024, 1, 1): the zone is dropped.
datetime.now(timezone.utc).date()Gives today's date in UTC, which can differ from date.today().

Do not confuse this method with the date class. After from datetime import date, datetime, date(2024, 3, 15) builds a date, while moment.date() extracts one.

Method signatures
python
datetime.date()
# returns: date with the same year, month, and day

Parameters

date() takes no parameters.

Return Value

Return ValueDescription
dateThe calendar day of the datetime, as seen in its own wall-clock fields.

Python Examples

Example 1 — Take the Date Part of a datetime

Extract the day from an evening timestamp and look at its type and repr.

python
from datetime import datetime

moment = datetime(2024, 3, 15, 18, 45, 10)
day = moment.date()
print(day)
print(type(day).__name__)
print(repr(day))

How It Works

  1. Time removed. Only year, month, and day survive, so printing shows 2024-03-15.
  2. New type. The result is a date, not a datetime at midnight.
  3. Repr check. repr() confirms the three fields and the class name.

Example 2 — Count Events per Calendar Day

Use date() as a dictionary key to group timestamps that fall on the same day.

python
from datetime import datetime

events = [
    datetime(2024, 3, 15, 9, 0),
    datetime(2024, 3, 15, 17, 30),
    datetime(2024, 3, 16, 8, 15),
]
counts = {}
for event in events:
    counts[event.date()] = counts.get(event.date(), 0) + 1
for day, total in counts.items():
    print(day.isoformat(), total)

How It Works

  1. Hashable keys. date objects are immutable and hashable, so they work as dictionary keys.
  2. Same day, same key. 09:00 and 17:30 on 15 March both map to date(2024, 3, 15).
  3. Insertion order. Dictionaries keep the order in which days first appeared, and isoformat() prints each key.

Example 3 — Get the Local Date and the UTC Date

At 08:00 in a UTC+11 zone it is still the previous day in UTC.

python
from datetime import datetime, timedelta, timezone

sydney_summer = timezone(timedelta(hours=11))
moment = datetime(2024, 1, 1, 8, 0, tzinfo=sydney_summer)

print(moment.date())
print(moment.astimezone(timezone.utc).date())
print(moment.date() == moment.astimezone(timezone.utc).date())

How It Works

  1. Own zone. date() reads the wall-clock fields, which say 1 January 2024.
  2. Convert first. 08:00 at UTC+11 is 21:00 UTC on 31 December, so the UTC date is a day earlier.
  3. Different days. The two dates differ, which matters for daily reports stored in UTC.

Frequently Asked Questions

Call moment.date(). It returns a date object such as date(2024, 3, 15).
Convert first: moment.date() == some_date. Ordering a datetime against a date raises TypeError.
No. date objects have no tzinfo. Convert with astimezone() before calling date() if you need a specific zone.
moment.date() extracts the day from an existing datetime; date.today() reads the clock.
Use datetime.combine(day, time()) for midnight, or another time object.

Next: datetime.dst()

Return the daylight saving adjustment as a timedelta, or None.

dst() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful