EasyNo. 1853LeetCode Premium
Convert Date Format — LeetCode 1853 Python Solution
- Topics
- Database
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
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".Example
+-------------+------+
| Column Name | Type |
+-------------+------+
| day | date |
+-------------+------+
day is the column with unique values for this table.Python solution
import duckdb
import pandas as pd
def solution(days: pd.DataFrame) -> pd.DataFrame:
con = duckdb.connect()
con.register("Days", days)
return con.execute("""SELECT DATE_FORMAT(day, '%W, %M %e, %Y') AS day FROM Days;""").df()Complexity
- Time
- O(n log n)(typical)
- Space · auxiliary
- O(n)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 0175 | Combine Two Tables | Easy |
| 0176 | Second Highest Salary | Medium |
| 0177 | Nth Highest Salary | Medium |
| 0178 | Rank Scores | Medium |
| 0180 | Consecutive Numbers | Medium |
| 0181 | Employees Earning More Than Their Managers | Easy |
Frequently asked questions
- How hard is LeetCode 1853. Convert Date Format?
LeetCode 1853. Convert Date Format is rated Easy on LeetCode.
- What topics does LeetCode 1853. Convert Date Format cover?
LeetCode 1853. Convert Date Format is tagged Database on LeetCode.
- Is LeetCode 1853. Convert Date Format a premium problem?
Yes. LeetCode 1853. Convert Date Format is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.