File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Datetime Formatting
2
+
3
+ You are likely very familiar with formating datetimes in Excel, with format strings such as "MM-DD-YYYY".
4
+ But Python has its own format strings that are, in my opinion, less intuitive.
5
+ So I've built the below table to help you translate between your current knowledge and Python.
6
+
7
+ For all examples below I will use the datetime ` 6/3/2002 01:04:09 `
8
+
9
+ | Excel Format | Python Format | Example |
10
+ | -------- | -------- | -------- |
11
+ | "M" | "%-m" | 6 |
12
+ | "MM" | "%m" | 06 |
13
+ | "MMM" | "%b" | Jun |
14
+ | "MMMM" | "%B" | June |
15
+ | "D" | "%-d" | 3 |
16
+ | "DD" | "%d" | 03 |
17
+ | "DDD" | "%a" | Fri |
18
+ | "DDDD" | "%A" | Friday |
19
+ | "YY" | "%y" | 02 |
20
+ | "YYYY" | "%Y" | 2002 |
21
+ | "H" | "%-H" | 1 |
22
+ | "HH" | "%H" | 01 |
23
+ | "M" | "%-M" | 4 |
24
+ | "MM" | "%M" | 04 |
25
+ | "S" | "%-S" | 9 |
26
+ | "SS" | "%S" | 09 |
You can’t perform that action at this time.
0 commit comments