#1853
Easy Database Convert date format
Database
85.0% acceptance
Apr 10, 2026
69
42
No description available.
Solution
Pandas
Time O(1)
Space O(1)
# Table: Days
#
# +-------------+------+
# | Column Name | Type |
# +-------------+------+
# | day | date |
# +-------------+------+
# day is the column with unique values for this table.
#
#
#
# Write a solution to convert each date in Days into a string formatted as "day_name, month_name day, year".
#
# Return the result table in any order.
#
# The result format is in the following example.
#
# Example 1:
# Input:
# Days table:
# +------------+
# | day |
# +------------+
# | 2022-04-12 |
# | 2021-08-09 |
# | 2020-06-26 |
# +------------+
# Output:
# +-------------------------+
# | day |
# +-------------------------+
# | Tuesday, April 12, 2022 |
# | Monday, August 9, 2021 |
# | Friday, June 26, 2020 |
# +-------------------------+
# Explanation: Please note that the output is case-sensitive.
import pandas as pd
def convert_date_format(days: pd.DataFrame) -> pd.DataFrame:
import platform
fmt = '%A, %B %#d, %Y' if platform.system() == 'Windows' else '%A, %B %-d, %Y'
days['day'] = pd.to_datetime(days['day']).dt.strftime(fmt)
return days