当前位置:首页 » 办公资讯 » 怎样在excel秀出来农历初几

怎样在excel秀出来农历初几

发布时间: 2022-04-30 03:07:57

‘壹’ 在excel表格中一列是公历日期,怎样可以在这一列的旁边显示出公历日期所对应的农历日期呢谢谢

Public Function NongLi(Optional XX_DATE As Date)

Dim MonthAdd(11), NongliData(99), TianGan(9), DiZhi(11), ShuXiang(11), DayName(30), MonName(12)
Dim curTime, curYear, curMonth, curDay
Dim GongliStr, NongliStr, NongliDayStr
Dim i, m, n, k, isEnd, bit, TheDate

'获取当前系统时间
curTime = XX_DATE

'天干名称
TianGan(0) = "甲"
TianGan(1) = "乙"
TianGan(2) = "丙"
TianGan(3) = "丁"
TianGan(4) = "戊"
TianGan(5) = "己"
TianGan(6) = "庚"
TianGan(7) = "辛"
TianGan(8) = "壬"
TianGan(9) = "癸"
'地支名称
DiZhi(0) = "子"
DiZhi(1) = "丑"
DiZhi(2) = "寅"
DiZhi(3) = "卯"
DiZhi(4) = "辰"
DiZhi(5) = "巳"
DiZhi(6) = "午"
DiZhi(7) = "未"
DiZhi(8) = "申"
DiZhi(9) = "酉"
DiZhi(10) = "戌"
DiZhi(11) = "亥"
'属相名称
ShuXiang(0) = "鼠"
ShuXiang(1) = "牛"
ShuXiang(2) = "虎"
ShuXiang(3) = "兔"
ShuXiang(4) = "龙"
ShuXiang(5) = "蛇"
ShuXiang(6) = "马"
ShuXiang(7) = "羊"
ShuXiang(8) = "猴"
ShuXiang(9) = "鸡"
ShuXiang(10) = "狗"
ShuXiang(11) = "猪"
'农历日期名
DayName(0) = "*"
DayName(1) = "初一"
DayName(2) = "初二"
DayName(3) = "初三"
DayName(4) = "初四"
DayName(5) = "初五"
DayName(6) = "初六"
DayName(7) = "初七"
DayName(8) = "初八"
DayName(9) = "初九"
DayName(10) = "初十"
DayName(11) = "十一"
DayName(12) = "十二"
DayName(13) = "十三"
DayName(14) = "十四"
DayName(15) = "十五"
DayName(16) = "十六"
DayName(17) = "十七"
DayName(18) = "十八"
DayName(19) = "十九"
DayName(20) = "二十"
DayName(21) = "廿一"
DayName(22) = "廿二"
DayName(23) = "廿三"
DayName(24) = "廿四"
DayName(25) = "廿五"
DayName(26) = "廿六"
DayName(27) = "廿七"
DayName(28) = "廿八"
DayName(29) = "廿九"
DayName(30) = "三十"
'农历月份名
MonName(0) = "*"
MonName(1) = "正"
MonName(2) = "二"
MonName(3) = "三"
MonName(4) = "四"
MonName(5) = "五"
MonName(6) = "六"
MonName(7) = "七"
MonName(8) = "八"
MonName(9) = "九"
MonName(10) = "十"
MonName(11) = "十一"
MonName(12) = "腊"
'公历每月前面的天数
MonthAdd(0) = 0
MonthAdd(1) = 31
MonthAdd(2) = 59
MonthAdd(3) = 90
MonthAdd(4) = 120
MonthAdd(5) = 151
MonthAdd(6) = 181
MonthAdd(7) = 212
MonthAdd(8) = 243
MonthAdd(9) = 273
MonthAdd(10) = 304
MonthAdd(11) = 334
'农历数据
NongliData(0) = 2635
NongliData(1) = 333387
NongliData(2) = 1701
NongliData(3) = 1748
NongliData(4) = 267701
NongliData(5) = 694
NongliData(6) = 2391
NongliData(7) = 133423
NongliData(8) = 1175
NongliData(9) = 396438
NongliData(10) = 3402
NongliData(11) = 3749
NongliData(12) = 331177
NongliData(13) = 1453
NongliData(14) = 694
NongliData(15) = 201326
NongliData(16) = 2350
NongliData(17) = 465197
NongliData(18) = 3221
NongliData(19) = 3402
NongliData(20) = 400202
NongliData(21) = 2901
NongliData(22) = 1386
NongliData(23) = 267611
NongliData(24) = 605
NongliData(25) = 2349
NongliData(26) = 137515
NongliData(27) = 2709
NongliData(28) = 464533
NongliData(29) = 1738
NongliData(30) = 2901
NongliData(31) = 330421
NongliData(32) = 1242
NongliData(33) = 2651
NongliData(34) = 199255
NongliData(35) = 1323
NongliData(36) = 529706
NongliData(37) = 3733
NongliData(38) = 1706
NongliData(39) = 398762
NongliData(40) = 2741
NongliData(41) = 1206
NongliData(42) = 267438
NongliData(43) = 2647
NongliData(44) = 1318
NongliData(45) = 204070
NongliData(46) = 3477
NongliData(47) = 46
NongliData(48) = 1386
NongliData(49) = 2413
NongliData(50) = 330077
NongliData(51) = 1197
NongliData(52) = 2637
NongliData(53) = 268877
NongliData(54) = 3365
NongliData(55) = 531109
NongliData(56) = 2900
NongliData(57) = 2922
NongliData(58) = 398042
NongliData(59) = 2395
NongliData(60) = 1179
NongliData(61) = 267415
NongliData(62) = 2635
NongliData(63) = 661067
NongliData(64) = 1701
NongliData(65) = 1748
NongliData(66) = 398772
NongliData(67) = 2742
NongliData(68) = 2391
NongliData(69) = 330031
NongliData(70) = 1175
NongliData(71) = 1611
NongliData(72) = 200010
NongliData(73) = 3749
NongliData(74) = 527717
NongliData(75) = 1452
NongliData(76) = 2742
NongliData(77) = 332397
NongliData(78) = 2350
NongliData(79) = 3222
NongliData(80) = 268949
NongliData(81) = 3402
NongliData(82) = 3493
NongliData(83) = 133973
NongliData(84) = 1386
NongliData(85) = 464219
NongliData(86) = 605
NongliData(87) = 2349
NongliData(88) = 334123
NongliData(89) = 2709
NongliData(90) = 2890
NongliData(91) = 267946
NongliData(92) = 2773
NongliData(93) = 592565
NongliData(94) = 1210
NongliData(95) = 2651
NongliData(96) = 395863
NongliData(97) = 1323
NongliData(98) = 2707
NongliData(99) = 265877
'生成当前公历年、月、日 ==> GongliStr
curYear = Year(curTime)
curMonth = Month(curTime)
curDay = Day(curTime)
GongliStr = curYear & "年"
If (curMonth < 10) Then
GongliStr = GongliStr & "0" & curMonth & "月"
Else
GongliStr = GongliStr & curMonth & "月"
End If
If (curDay < 10) Then
GongliStr = GongliStr & "0" & curDay & "日"
Else
GongliStr = GongliStr & curDay & "日"
End If
'计算到初始时间1921年2月8日的天数:1921-2-8(正月初一)
TheDate = (curYear - 1921) * 365 + Int((curYear - 1921) / 4) + curDay + MonthAdd(curMonth - 1) - 38
If ((curYear Mod 4) = 0 And curMonth > 2) Then
TheDate = TheDate + 1
End If
'计算农历天干、地支、月、日
isEnd = 0
m = 0
Do
If (NongliData(m) < 4095) Then
k = 11
Else
k = 12
End If
n = k
Do
If (n < 0) Then
Exit Do
End If
'获取NongliData(m)的第n个二进制位的值
bit = NongliData(m)
For i = 1 To n Step 1
bit = Int(bit / 2)
Next
bit = bit Mod 2
If (TheDate <= 29 + bit) Then
isEnd = 1
Exit Do
End If
TheDate = TheDate - 29 - bit
n = n - 1
Loop
If (isEnd = 1) Then
Exit Do
End If
m = m + 1
Loop
curYear = 1921 + m
curMonth = k - n + 1
curDay = TheDate
If (k = 12) Then
If (curMonth = (Int(NongliData(m) / 65536) + 1)) Then
curMonth = 1 - curMonth
ElseIf (curMonth > (Int(NongliData(m) / 65536) + 1)) Then
curMonth = curMonth - 1
End If
End If
'生成农历天干、地支、属相 ==> NongliStr
NongliStr = "农历" & TianGan(((curYear - 4) Mod 60) Mod 10) & DiZhi(((curYear - 4) Mod 60) Mod 12) & "年"
NongliStr = NongliStr & "(" & ShuXiang(((curYear - 4) Mod 60) Mod 12) & ")"
'生成农历月、日 ==> NongliDayStr
If (curMonth < 1) Then
NongliDayStr = "闰" & MonName(-1 * curMonth)
Else
NongliDayStr = MonName(curMonth)
End If
NongliDayStr = NongliDayStr & "月"
NongliDayStr = NongliDayStr & DayName(curDay)

NongLi = NongliStr & NongliDayStr

End Function

将上面这段代码保存在模块中,就可以用公式
=nongli(A1)
调用了。

‘贰’ 求Excel里显示农历的函数

使用自定义函数才能够实现。
或者用这个公式:
=TEXT(A1,"[$-130000]yyyy年m月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"d")

用法:A1有公历日期,形如2013/2/14
在其它单元格中输入上面的公式,将得到结果,如上面的日期可得到:2013年1月初5

‘叁’ excel 怎么拖出农历的日期

在Excel使用农历日期只有两种办法:要么手动输入;要么自行做一个模板;虽然后者涉及到使用Excel里的函数,但却没办法,因为这是必须的。

另外,关于这个模板的程序代码,你可以到这里看看:

‘肆’ 怎样可以在excel中自动填充农历日期呢

1、可以点击单元格,直接输入日期。

‘伍’ 在EXCEL中怎样把公历转换成农历

在EXCEL中把公历转换成农历的方法及具体操作步骤如下,以WPS中EXCEL为例做演示。

1、在电脑中打开需要操作的EXCEL表格,如需要将A1的日期转成农历,如下图所示。


‘陆’ excel里将时间显视为农历用什么公式

1、VBA
Dim WeekName(7), MonthAdd(11), NongliData(99), TianGan(9), DiZhi(11), ShuXiang(11), DayName(30), MonName(12)
Dim curTime, curYear, curMonth, curDay, curWeekday
Dim GongliStr, WeekdayStr, NongliStr, NongliDayStr
Dim i, m, n, k, isEnd, bit, TheDate
Private Sub Form_Load()
'获取当前系统时间
curTime = Now()
'星期名
WeekName(0) = " * "
WeekName(1) = "星期日"
WeekName(2) = "星期一"
WeekName(3) = "星期二"
WeekName(4) = "星期三"
WeekName(5) = "星期四"
WeekName(6) = "星期五"
WeekName(7) = "星期六"
'天干名称
TianGan(0) = "甲"
TianGan(1) = "乙"
TianGan(2) = "丙"
TianGan(3) = "丁"
TianGan(4) = "戊"
TianGan(5) = "己"
TianGan(6) = "庚"
TianGan(7) = "辛"
TianGan(8) = "壬"
TianGan(9) = "癸"
'地支名称
DiZhi(0) = "子"
DiZhi(1) = "丑"
DiZhi(2) = "寅"
DiZhi(3) = "卯"
DiZhi(4) = "辰"
DiZhi(5) = "巳"
DiZhi(6) = "午"
DiZhi(7) = "未"
DiZhi(8) = "申"
DiZhi(9) = "酉"
DiZhi(10) = "戌"
DiZhi(11) = "亥"
'属相名称
ShuXiang(0) = "鼠"
ShuXiang(1) = "牛"
ShuXiang(2) = "虎"
ShuXiang(3) = "兔"
ShuXiang(4) = "龙"
ShuXiang(5) = "蛇"
ShuXiang(6) = "马"
ShuXiang(7) = "羊"
ShuXiang(8) = "猴"
ShuXiang(9) = "鸡"
ShuXiang(10) = "狗"
ShuXiang(11) = "猪"
'农历日期名
DayName(0) = "*"
DayName(1) = "初一"
DayName(2) = "初二"
DayName(3) = "初三"
DayName(4) = "初四"
DayName(5) = "初五"
DayName(6) = "初六"
DayName(7) = "初七"
DayName(8) = "初八"
DayName(9) = "初九"
DayName(10) = "初十"
DayName(11) = "十?quot;"
DayName(12) = "十二"
DayName(13) = "十三"
DayName(14) = "十四"
DayName(15) = "十五"
DayName(16) = "十六"
DayName(17) = "十七"
DayName(18) = "十八"
DayName(19) = "十九"
DayName(20) = "二十"
DayName(21) = "廿一"
DayName(22) = "廿二"
DayName(23) = "廿三"
DayName(24) = "廿四"
DayName(25) = "廿五"
DayName(26) = "廿六"
DayName(27) = "廿七"
DayName(28) = "廿八"
DayName(29) = "廿九"
DayName(30) = "三十"
'农历月份名
MonName(0) = "*"
MonName(1) = "正"
MonName(2) = "二"
MonName(3) = "三"
MonName(4) = "四"
MonName(5) = "五"
MonName(6) = "六"
MonName(7) = "七"
MonName(8) = "八"
MonName(9) = "九"
MonName(10) = "十"
MonName(11) = "十一"
MonName(12) = "腊"
'公历每月前面的天数
MonthAdd(0) = 0
MonthAdd(1) = 31
MonthAdd(2) = 59
MonthAdd(3) = 90
MonthAdd(4) = 120
MonthAdd(5) = 151
MonthAdd(6) = 181
MonthAdd(7) = 212
MonthAdd(8) = 243
MonthAdd(9) = 273
MonthAdd(10) = 304
MonthAdd(11) = 334
'农历数据
NongliData(0) = 2635
NongliData(1) = 333387
NongliData(2) = 1701
NongliData(3) = 1748
NongliData(4) = 267701
NongliData(5) = 694
NongliData(6) = 2391
NongliData(7) = 133423
NongliData(8) = 1175
NongliData(9) = 396438
NongliData(10) = 3402
NongliData(11) = 3749
NongliData(12) = 331177
NongliData(13) = 1453
NongliData(14) = 694
NongliData(15) = 201326
NongliData(16) = 2350
NongliData(17) = 465197
NongliData(18) = 3221
NongliData(19) = 3402
NongliData(20) = 400202
NongliData(21) = 2901
NongliData(22) = 1386
NongliData(23) = 267611
NongliData(24) = 605
NongliData(25) = 2349
NongliData(26) = 137515
NongliData(27) = 2709
NongliData(28) = 464533
NongliData(29) = 1738
NongliData(30) = 2901
NongliData(31) = 330421
NongliData(32) = 1242
NongliData(33) = 2651
NongliData(34) = 199255
NongliData(35) = 1323
NongliData(36) = 529706
NongliData(37) = 3733
NongliData(38) = 1706
NongliData(39) = 398762
NongliData(40) = 2741
NongliData(41) = 1206
NongliData(42) = 267438
NongliData(43) = 2647
NongliData(44) = 1318
NongliData(45) = 204070
NongliData(46) = 3477
NongliData(47) = 46
NongliData(48) = 1386
NongliData(49) = 2413
NongliData(50) = 330077
NongliData(51) = 1197
NongliData(52) = 2637
NongliData(53) = 268877
NongliData(54) = 3365
NongliData(55) = 531109
NongliData(56) = 2900
NongliData(57) = 2922
NongliData(58) = 398042
NongliData(59) = 2395
NongliData(60) = 1179
NongliData(61) = 267415
NongliData(62) = 2635
NongliData(63) = 661067
NongliData(64) = 1701
NongliData(65) = 1748
NongliData(66) = 398772
NongliData(67) = 2742
NongliData(68) = 2391
NongliData(69) = 330031
NongliData(70) = 1175
NongliData(71) = 1611
NongliData(72) = 200010
NongliData(73) = 3749
NongliData(74) = 527717
NongliData(75) = 1452
NongliData(76) = 2742
NongliData(77) = 332397
NongliData(78) = 2350
NongliData(79) = 3222
NongliData(80) = 268949
NongliData(81) = 3402
NongliData(82) = 3493
NongliData(83) = 133973
NongliData(84) = 1386
NongliData(85) = 464219
NongliData(86) = 605
NongliData(87) = 2349
NongliData(88) = 334123
NongliData(89) = 2709
NongliData(90) = 2890
NongliData(91) = 267946
NongliData(92) = 2773
NongliData(93) = 592565
NongliData(94) = 1210
NongliData(95) = 2651
NongliData(96) = 395863
NongliData(97) = 1323
NongliData(98) = 2707
NongliData(99) = 265877
'生成当前公历年、月、日 ==> GongliStr
curYear = Year(curTime)
curMonth = Month(curTime)
curDay = Day(curTime)
GongliStr = curYear & "年"
If (curMonth < 10) Then
GongliStr = GongliStr & "0" & curMonth & "月"
Else
GongliStr = GongliStr & curMonth & "月"
End If
If (curDay < 10) Then
GongliStr = GongliStr & "0" & curDay & "日"
Else
GongliStr = GongliStr & curDay & "日"
End If
'生成当前公历星期 ==> WeekdayStr
curWeekday = Weekday(curTime)
WeekdayStr = WeekName(curWeekday)
'计算到初始时间1921年2月8日的天数:1921-2-8(正月初一)
TheDate = (curYear - 1921) * 365 + Int((curYear - 1921) / 4) + curDay + MonthAdd(curMonth - 1) - 38
If ((curYear Mod 4) = 0 And curMonth > 2) Then
TheDate = TheDate + 1
End If
'计算农历天干、地支、月、日
isEnd = 0
m = 0
Do
If (NongliData(m) < 4095) Then
k = 11
Else
k = 12
End If
n = k
Do
If (n < 0) Then
Exit Do
End If
'获取NongliData(m)的第n个二进制位的值
bit = NongliData(m)
For i = 1 To n Step 1
bit = Int(bit / 2)
Next
bit = bit Mod 2
If (TheDate <= 29 + bit) Then
isEnd = 1
Exit Do
End If
TheDate = TheDate - 29 - bit
n = n - 1
Loop
If (isEnd = 1) Then
Exit Do
End If
m = m + 1
Loop
curYear = 1921 + m
curMonth = k - n + 1
curDay = TheDate
If (k = 12) Then
If (curMonth = (Int(NongliData(m) / 65536) + 1)) Then
curMonth = 1 - curMonth
ElseIf (curMonth > (Int(NongliData(m) / 65536) + 1)) Then
curMonth = curMonth - 1
End If
End If
'生成农历天干、地支、属相 ==> NongliStr
NongliStr = "农历" & TianGan(((curYear - 4) Mod 60) Mod 10) & DiZhi(((curYear - 4) Mod 60) Mod 12) & "年"
NongliStr = NongliStr & "(" & ShuXiang(((curYear - 4) Mod 60) Mod 12) & ")"
'生成农历月、日 ==> NongliDayStr
If (curMonth < 1) Then
NongliDayStr = "闰" & MonName(-1 * curMonth)
Else
NongliDayStr = MonName(curMonth)
End If
NongliDayStr = NongliDayStr & "月"
NongliDayStr = NongliDayStr & DayName(curDay)
MsgBox NongliStr & NongliDayStr
End Sub
2、请到下面的网址下载加载宏文件

‘柒’ Excel 有什么办法可将当前日期显示变成农历时间

办法肯定有,就看你能不能接受了。我给出的方法,不需要写公式,只需要调用命令就可以了。看,只要这一个函数,就出来农历了,非常简单。这是一个Excel的加载宏,里面包含了天数计算,节气、公历转农历、农历转公历等一系列函数,很强大。补上下载地址:密码:u3at

‘捌’ excel里如何得到当天的农历日期

'函数作用:阴阳历转换和阴阳历生日

'说明:适用于1901-2100年间

'示例:=lunar("2006-11-1")求阳历2006-11-1日对应的阴历

'=solar("2006-1-1")求阴历2006年正月初一对应的阳历

'=lunarbirth("1975-5-6")阴历生日:阳历1975年5月6日出生,今年阴历生日时对应的阳历日期

'=solarbirth("1975-5-6")阳历生日:阳历1975年5月6日出生,今年阳历生日时对应的阳历日期



TypeConvDataA
leapmonthAsInteger
Month(1To13)AsInteger
sp_monthAsInteger'SolarmonthofSpringFestival
sp_dayAsInteger'SolardayofSpringFestival
EndType

PrivateFunctionLunarData(q_year)AsConvDataA
DimdAsLong
DimMonth(1To13)AsInteger
'1901-2100
LunarCal=Array(&H4AE53,&HA5748,&H5526BD,&HD2650,&HD9544,&H46AAB9,&H56A4D,&H9AD42,&H24AEB6,&H4AE4A,_
&H6A4DBE,&HA4D52,&HD2546,&H5D52BA,&HB544E,&HD6A43,&H296D37,&H95B4B,&H749BC1,&H49754,_
&HA4B48,&H5B25BC,&H6A550,&H6D445,&H4ADAB8,&H2B64D,&H95742,&H2497B7,&H4974A,&H664B3E,_
&HD4A51,&HEA546,&H56D4BA,&H5AD4E,&H2B644,&H393738,&H92E4B,&H7C96BF,&HC9553,&HD4A48,_
&H6DA53B,&HB554F,&H56A45,&H4AADB9,&H25D4D,&H92D42,&H2C95B6,&HA954A,&H7B4ABD,&H6CA51,_
&HB5546,&H555ABB,&H4DA4E,&HA5B43,&H352BB8,&H52B4C,&H8A953F,&HE9552,&H6AA48,&H7AD53C,_
&HAB54F,&H4B645,&H4A5739,&HA574D,&H52642,&H3E9335,&HD9549,&H75AABE,&H56A51,&H96D46,_
&H54AEBB,&H4AD4F,&HA4D43,&H4D26B7,&HD254B,&H8D52BF,&HB5452,&HB6A47,&H696D3C,&H95B50,_
&H49B45,&H4A4BB9,&HA4B4D,&HAB25C2,&H6A554,&H6D449,&H6ADA3D,&HAB651,&H93746,&H5497BB,_
&H4974F,&H64B44,&H36A537,&HEA54A,&H86B2BF,&H5AC53,&HAB647,&H5936BC,&H92E50,&HC9645,_
&H4D4AB8,&HD4A4C,&HDA541,&H25AA36,&H56A49,&H7AADBD,&H25D52,&H92D47,&H5C95BA,&HA954E,_
&HB4A43,&H4B5537,&HAD54A,&H955ABF,&H4BA53,&HA5B48,&H652BBC,&H52B50,&HA9345,&H474AB9,_
&H6AA4C,&HAD541,&H24DAB6,&H4B64A,&H69573D,&HA4E51,&HD2646,&H5E933A,&HD534D,&H5AA43,_
&H36B537,&H96D4B,&HB4AEBF,&H4AD53,&HA4D48,&H6D25BC,&HD254F,&HD5244,&H5DAA38,&HB5A4C,_
&H56D41,&H24ADB6,&H49B4A,&H7A4BBE,&HA4B51,&HAA546,&H5B52BA,&H6D24E,&HADA42,&H355B37,_
&H9374B,&H8497C1,&H49753,&H64B48,&H66A53C,&HEA54F,&H6B244,&H4AB638,&HAAE4C,&H92E42,_
&H3C9735,&HC9649,&H7D4ABD,&HD4A51,&HDA545,&H55AABA,&H56A4E,&HA6D43,&H452EB7,&H52D4B,_
&H8A95BF,&HA9553,&HB4A47,&H6B553B,&HAD54F,&H55A45,&H4A5D38,&HA5B4C,&H52B42,&H3A93B6,_
&H69349,&H7729BD,&H6AA51,&HAD546,&H54DABA,&H4B64E,&HA5743,&H452738,&HD264A,&H8E933E,_
&HD5252,&HDAA47,&H66B53B,&H56D4F,&H4AE45,&H4A4EB9,&HA4D4C,&HD1541,&H2D92B5,&HD5349)
startyear=1901
ng=LunarCal(q_year-startyear)
d=&H100000
LunarData.leapmonth=Int(ng/d)
ng=ngModd
d=&H80
mdata=Int(ng/d)
ng=ngModd
d=&H20
LunarData.sp_month=Int(ng/d)
LunarData.sp_day=ngModd
d=&H1000
i=1
Do
LunarData.Month(i)=29+Int(mdata/d)
mdata=mdataModd
Ifd=1ThenExitDo
d=d/2
i=i+1
Loop
IfLunarData.leapmonth=0ThenLunarData.Month(i)=0
EndFunction

Functionlunar(Solar_dateAsDate,OptionalPartAsInteger=0)AsString
'Part=0,all;Part=1,lunaryear;Part=2,lunarmonth;Part=3,lunarday
DimaAsConvDataA
l_year=Year(Solar_date)
a=LunarData(l_year)
sp_date=DateSerial(l_year,a.sp_month,a.sp_day)
Ifsp_date>Solar_dateThen
l_year=l_year-1
a=LunarData(l_year)
sp_date=DateSerial(l_year,a.sp_month,a.sp_day)
EndIf
l_day=Solar_date-sp_date
l_month=1
IS_lunar_leapmonth=False
y=a.Month(l_month)
DoWhilel_day>=y
l_day=l_day-y
Ifl_month=a.leapmonthThenIS_lunar_leapmonth=(NotIS_lunar_leapmonth)
IfIS_lunar_leapmonthThen
y=a.Month(13)
Else
l_month=l_month+1
y=a.Month(l_month)
EndIf
Loop
l_day=l_day+1
lunar=l_year&"-"&l_month&"-"&l_day
IfIS_lunar_leapmonthThenlunar=lunar&"-L"
lunar=Choose(Part+1,lunar,l_year,l_month,l_day)
EndFunction

Functionsolar(Lunar_date,OptionalIS_lunar_leapmonthAsInteger=0)AsString
'IS_lunar_leapmonth=0,Noleapmonth;IS_lunar_leapmonth=1,isleapmonth
DimaAsConvDataA
Lunar_date=Split(Lunar_date,"-")
s_year=Lunar_date(0)
ForEachCInLunar_date
IfC="L"ThenIS_lunar_leapmonth=1
Next
a=LunarData(s_year)
sp_date=DateSerial(s_year,a.sp_month,a.sp_day)
IfLunar_date(1)<>a.leapmonthThenIS_lunar_leapmonth=0
x=Lunar_date(2)
tm=Lunar_date(1)+IS_lunar_leapmonth-1
Fori=1Totm
x=x+a.Month(i)
Ifi=a.leapmonthAndIS_lunar_leapmonth=0Then
x=x+a.Month(13)
EndIf
Next
s_date=sp_date+x-1
solar=s_date
EndFunction

Functionlunarbirth(Solar_birthdayAsDate,OptionalInquire_yearAsInteger)AsString
IfInquire_year=0Then
Inquire_year=Left(lunar(Now),4)
lunarbirth=solar(Inquire_year&Mid(lunar(Solar_birthday),5,10))
IfCDate(lunarbirth)<Now-1ThenInquire_year=Inquire_year+1
EndIf
lunarbirth=solar(Inquire_year&Mid(lunar(Solar_birthday),5,10))
EndFunction

Functionsolarbirth(Solar_birthdayAsDate,OptionalInquire_yearAsInteger)AsString
IfInquire_year=0Then
Inquire_year=Year(Now)
solarbirth=DateSerial(Inquire_year,Month(Solar_birthday),Day(Solar_birthday))
IfCDate(solarbirth)<Now-1ThenInquire_year=Inquire_year+1
EndIf
solarbirth=DateSerial(Inquire_year,Month(Solar_birthday),Day(Solar_birthday))
EndFunction

‘玖’ 怎么样在excel身份证怎么算出阴历(农历)生日,员工太多了,一个个查也太费劲了,网上搜过没有解决方案

A2是一个身份证号码,

B2提取阳历生日,公式为:

=TEXT(MID(A2,7,8),"####-##-##")

C2转化阴历生日,公式为:

=TEXT(B2,"[$-130000][DBNum1]yyyy年m月"&IF(--TEXT(B2,"[$-130000][DBNum4]d")<11,"初","")&"d")

‘拾’ excel怎么设置去年同期农历时间

=TEXT(EDATE(A1,-12),"[$-130000]YYYY-M-D")

不过2020年有闰月(闰4月),闰月后面的农历月份显示的都不对,腊月会显示13月,推算公式好像挺复杂,建议通过后台写VBA/从网上抓取结果

热点内容
马路上汽车的噪音在多少分贝 发布:2023-08-31 22:08:23 浏览:1811
应孕棒多少钱一盒 发布:2023-08-31 22:08:21 浏览:1293
标准养老金一年能领多少钱 发布:2023-08-31 22:05:05 浏览:1577
湖北通城接网线多少钱一个月 发布:2023-08-31 21:59:51 浏览:1662
开随车吊车多少钱一个月 发布:2023-08-31 21:55:06 浏览:1420
京东付尾款怎么知道前多少名 发布:2023-08-31 21:52:58 浏览:1743
在学校租铺面一个月要多少钱 发布:2023-08-31 21:52:09 浏览:1875
2寸有多少厘米 发布:2023-08-31 21:50:34 浏览:1523
知道电压如何算一小时多少电 发布:2023-08-31 21:46:20 浏览:1499
金手镯54号圈周长是多少厘米 发布:2023-08-31 21:44:28 浏览:1682