How to calculate the month in heavenly stems and earthly branches?

Monthly dry and branch calculation formula:

1, monthly stem sequence = (year mantissa +2)*2+ month (mantissa in bits).

2. Month branch order = month +2 (if it is greater than 12, it will also be subtracted from 12).

For example, for the trunk line of 2065438+May 2005, the monthly trunk line sequence =(5+2)*2+5= 19. If the mantissa is 9, then the trunk line sequence is nonyl. The order of monthly branch =5+2=7 is noon, and the main branch of 2065438+May 2005 is Renwu.

Extended data:

Different dynasties began to build different branches of the moon in different ages. It is cloudy in the first month, hairy in February and Chen in March. This is the summer calendar. The first month of the Shang calendar is ugly, the second month is cloudy and the third month is hairy. The Zhou calendar was built in the first month, ugly February and Yin San month.

The Qin calendar began in the year of Jian Hai, but it is still called October. It was not until Emperor Wu of the Han Dynasty changed the calendar that Xia Zheng was reused, that is, the first day of the first month was the beginning of the year (Wu Zetian changed Zhou Zheng and Jianzi), which has been used ever since.

Ganzhi Song formula:

The months of trunks and branches are easy to calculate, and the branches are fixed every year, as long as the calculated trunks and branches are fixed every month. There is a verse to prove it (for the first month, Yin is a tiger, also known as "five tigers dun Yuan"):

1, Year A and Year B starts from C, every year is Year A and Year B, and the first month starts from C. ..

2. Party B is at the age of Geng, with E as the head. Every year is the year of Party B or Geng, and the monthly work in the first month starts from E..

3. Party C must look for Geng Xu, and every year is the year of C or Xin, and the monthly work in the first month begins with Geng Xu.

4. Ding Ren is downstream. Every year is the year of Ding or Min, and the first month begins with Min.

5, there is more to be found, just pursue good news. Every year is the 1898 or Guisi year, and the first month begins with Jiaxu.

Baidu Encyclopedia-heavenly stems and earthly branches