Calculating Chinese Year, Month, and Day with the Celestial Stem & Terrestrial Branch Algorithm
This article explains the ten Celestial Stems and twelve Terrestrial Branches, their symbolic meanings, the 60‑year cycle, and provides step‑by‑step formulas to compute the stem‑branch pair for a given year, month, and day, illustrated with a 2010 example.
Celestial Stem (天干) and Terrestrial Branch (地支) are traditional Chinese ordering symbols. There are ten stems – 甲, 乙, 丙, 丁, 戊, 己, 庚, 辛, 壬, 癸 – and twelve branches – 子, 丑, 寅, 卯, 辰, 巳, 午, 未, 申, 酉, 戌, 亥 – each used cyclically.
Symbolic meanings
Stem 甲: grass breaking through soil, armor metaphor.
Stem 乙: tender new growth.
Stem 丙: bright sun.
Stem 丁: robust growth.
Stem 戊: flourishing vegetation.
Stem 己: rising.
Stem 庚: renewal after harvest.
Stem 辛: newness, sharp flavor.
Stem 壬: gestation of yang.
Stem 癸: hidden sprouting.
Branch 子: beginning of yang.
Branch 丑: sprouting in soil.
Branch 寅: spring emergence.
Branch 卯: flourishing under east sun.
Branch 辰: vibration and rise.
Branch 巳: pure yang after yin fades.
Branch 午: fullness of yang.
Branch 未: ripe fruit.
Branch 申: completed growth.
Branch 酉: retreat and contraction.
Branch 戌: decay.
Branch 亥: extreme yin.
60‑year cycle (甲子)
01.甲子 02.乙丑 03.丙寅 04.丁卯 05.戊辰 06.己巳 07.庚午 08.辛未 09.壬申 10.癸酉 11.甲戌 12.乙亥 13.丙子 14.丁丑 15.戊寅 16.己卯 17.庚辰 18.辛巳 19.壬午 20.癸未 21.甲申 22.乙酉 23.丙戌 24.丁亥 25.戊子 26.己丑 27.庚寅 28.辛卯 29.壬辰 30.癸巳 31.甲午 32.乙未 33.丙申 34.丁酉 35.戊戌 36.己亥 37.庚子 38.辛丑 39.壬寅 40.癸卯 41.甲辰 42.乙巳 43.丙午 44.丁未 45.戊申 46.己酉 47.庚戌 48.辛亥 49.壬子 50.癸丑 51.甲寅 52.乙卯 53.丙辰 54.丁己 55.戊午 56.己未 57.庚申 58.辛酉 59.壬戌 60.癸亥
Year calculation
Celestial Stem = (Year – 3) Mod 10
Terrestrial Branch = (Year – 3) Mod 12Using arrays indexed from 0, the stem index 0 corresponds to 癸, 1 to 甲, …, 9 to 壬; the branch index 0 corresponds to 亥, 1 to 子, …, 11 to 戌.
Example: Year = 2010 → Stem index = (2010‑3) Mod 10 = 7 → 庚; Branch index = (2010‑3) Mod 12 = 3 → 寅; therefore 2010 is 庚寅.
Month calculation (first month)
First‑month stem = 2 × YearStem − 4 ± 5, where +5 is used if YearStem < 5, otherwise − 5.
First‑month branch = Year branch.
YearStem = 7 (for 2010, >5) → FirstMonthStem = 2×7‑4‑5 = 5 → 戊
FirstMonth = 戊寅Day calculation
Let C = first two digits of year, Y = last two digits, M = month number, D = day, I = 0 for odd month, 6 for even month. [] denotes integer part.
DayStemTotal G = 4*C + [C/4] + [5*Y] + [Y/4] + [3*(M+1)/5] + D – 3
DayBranchTotal Z = G + 4*C + 10 + I
DayStem = G Mod 10
DayBranch = Z Mod 12Example for 2010‑10‑07 (C=20, Y=10, M=10, D=7, I=6):
G = 4*20 + [20/4] + 5*10 + [10/4] + [3*(10+1)/5] + 7 – 3 = 147
Z = 147 + 4*20 + 10 + 6 = 243
DayStem = 147 Mod 10 = 7 → 庚
DayBranch = 243 Mod 12 = 3 → 寅
Result: 庚寅24‑hour to 12‑shichen mapping
子: 23‑01
丑: 01‑03
寅: 03‑05
卯: 05‑07
辰: 07‑09
巳: 09‑11
午: 11‑13
未: 13‑15
申: 15‑17
酉: 17‑19
戌: 19‑21
亥: 21‑23
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
