print then.date()

What you want is a datetime.date object. What you have is a datetime.datetime object. You can either change the object when you print as per above, or do the following when creating the object:

then = datetime.datetime.strptime(when, '%Y-%m-%d').date()
Answer from Woody Pride on Stack Overflow
Discussions

python - removing time from date&time variable in pandas? - Stack Overflow
Also, none of the Pandas type checkers ... date (or datetime) column, as it's now just a Python object column no Pandas. If this is really what you want, then fine. However, I would normally elect to only do this just before serialising to another format (csv, JSON, etc.) so that these can benefit from not having the time component ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
datetime - Remove time in date format in Python - Stack Overflow
You can use .date() on datetime objects to 'remove' the time. More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Remove time portion of DateTime index in pandas - Stack Overflow
When I query a service through their API for daily data, they throw in a time portion which is equal to whatever time the query was made. So my pandas dataframe looks like this when I called the fu... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Remove Time in Date
Please show me how to remove the time in date. I am getting this output in my template: 114 days, 0:00:00 My prefer output is just 114 without the 0:00:00. Below is the code: models.py: class Server(models.Model): โ€ฆ More on forum.djangoproject.com
๐ŸŒ forum.djangoproject.com
1
0
January 23, 2024
๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ python โ€บ python date โ€บ remove time from datetime in python
Remove Time from datetime in Python [5 ways] - Java2Blog
November 25, 2023 - In Python programming, dealing with date and time is a common scenario. Often, thereโ€™s a need to manipulate datetime objects, such as extracting only the date part and discarding the time. For instance, consider a datetime object representing 2023-11-24 15:30:00. The goal is to transform this into just the date 2023-11-24, removing the time component.
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-remove-time-from-datetime-variable-in-pandas
How to Remove Time from DateTime Variable in Pandas | Saturn Cloud Blog
November 7, 2023 - # Remove time from the datetime object date_var = date_time_obj.dt.date ยท The final step is to convert the result to a string if required. We can achieve this by using the strftime() function provided by the datetime module in Python.
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ pandas-remove-time-from-datetime
How to remove Time from DateTime in Pandas [5 Ways] | bobbyhadz
Copied!import pandas as pd df = ... object # date datetime64[ns] # dtype: object print(df.dtypes) ... You can also use the dt.strftime() method to remove the time from a datetime object....
๐ŸŒ
YouTube
youtube.com โ€บ statistics globe
Remove Time from datetime in Python (Example) | Display & Print Only Date | Apply date() Function - YouTube
How to display a datetime object without the time component in the Python programming language. More details: https://statisticsglobe.com/remove-time-from-da...
Published ย  November 11, 2022
Views ย  1K
๐ŸŒ
Statistics Globe
statisticsglobe.com โ€บ home โ€บ python programming language for statistics & data science โ€บ remove time from datetime in python (example)
Remove Time from datetime (Python Example) | Display & Print Only Date
January 26, 2023 - This example explains how to drop the time element of a datetime object. For this task, we can use the date function as shown in the following Python code: my_date = my_datetime.date() # Apply date function print(my_date) # Print only date # 2022-03-25 ยท Have a look at the previously shown output: We have removed the time of our datetime object.
Find elsewhere
๐ŸŒ
Finxter
blog.finxter.com โ€บ 5-best-ways-to-remove-hours-minutes-and-seconds-from-python-datetime
5 Best Ways to Remove Hours, Minutes, and Seconds from Python datetime โ€“ Be on the Right Side of Change
February 28, 2024 - Combine the date part of the datetime object with the minimum possible time value using the datetime.combine() function. Itโ€™s a neat and clear method to strip the time component. ... from datetime import datetime original_datetime = datetime(2023, 3, 18, 15, 23, 31) truncated_datetime = ...
๐ŸŒ
Luasoftware
code.luasoftware.com โ€บ tutorials โ€บ python โ€บ python-datetime-remove-millliseconds-and-seconds
Python Datetime Remove Millliseconds and Seconds (or time)
February 21, 2021 - Related articlesTypeError: can't subtract offset-naive and offset-aware datetimes (Python)Python Diff Between Two Dates (Days, Hours, Minutes, Seconds)Python TypeError: can't subtract offset-naive and offset-aware datetimesPython Check datetime With No/Zero/Midnight TimePython Replace Time in DatetimePython Get Today Date Without TimePython Convert UTC to TimezonePython Datetime Now UtcPython Get Current Date & TimePython Parse String to datetimePython Format datetime
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ datetime.html
datetime โ€” Basic date and time types
datetime2 is a duration of timedelta removed from datetime1, moving forward in time if timedelta.days > 0, or backward if timedelta.days < 0. The result has the same tzinfo attribute as the input datetime, and datetime2 - datetime1 == timedelta after. OverflowError is raised if datetime2.year would be smaller than MINYEAR or larger than MAXYEAR.
๐ŸŒ
Iditect
iditect.com โ€บ faq โ€บ python โ€บ display-python-datetime-without-time.html
Display Python datetime without time
from datetime import datetime # Get current date and time now = datetime.now() # Remove time component date_only = now.replace(hour=0, minute=0, second=0, microsecond=0) print("Date without time:", date_only) "Python print date only" Description: Discover how to print only the date part of a datetime object in Python.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-remove-timezone-information-from-datetime-object-in-python
How to remove timezone information from DateTime object in Python - GeeksforGeeks
December 9, 2021 - 2 min read Datetime to integer timestamp in Python ยท A timestamp represents the number of seconds that have passed since January 1, 1970, 00:00:00 UTC (also known as the epoch). We can convert a datetime object to a timestamp using the built-in timestamp() method, and then round or typecast it to get an integer version. In this article, we'll learn ho ยท 3 min read How to remove timezone from a Timestamp column in a Pandas Dataframe
๐ŸŒ
Django Forum
forum.djangoproject.com โ€บ using django โ€บ templates & frontend
Remove Time in Date - Templates & Frontend - Django Forum
January 23, 2024 - Please show me how to remove the time in date. I am getting this output in my template: 114 days, 0:00:00 My prefer output is just 114 without the 0:00:00. Below is the code: models.py: class Server(models.Model): server_name = models.CharField(unique=True, max_length=30) server_warrantyexpiry = models.DateField(auto_now=False, auto_now_add=False) def daysleft(self): today = date.today() daysleft = self.server_warrantyexpiry - today return daysleft template: {% ...
๐ŸŒ
Quora
quora.com โ€บ How-can-I-delete-minutes-seconds-and-microseconds-from-a-timestamp-value-using-Python-For-example-I-have-1508265552-which-is-10-17-2017-6-39pm-I-want-to-get-1508263200-which-is-same-day-but-6-00pm
How can I delete minutes, seconds and microseconds from a timestamp value using Python? For example, I have 1508265552 which is 10/17/201...
Answer (1 of 7): Here you go. Remove the remainder from the timestamp divided by 3600 (Number of seconds in a hour) BTW the timestamp is the number of seconds from since midnight Universal Time (UTC) of January 1, 1970. No microseconds involved. $ python >>> time = 1508265552 >>> def remove_r...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ remove-seconds-from-the-datetime-in-python
Remove Seconds from the Datetime in Python - GeeksforGeeks
July 23, 2025 - Below are the possible approaches to remove seconds from the Datetime in Python: Using replace method of datetime class.