c语言计算复活节计算
Easter has passed for this year, but it's never too early to figure out when Easter will occur next year. Then, you can book your vacation for that date, and be out of town when the family shows up for Easter dinner!
今年的复活节已经过去了,但是弄清楚明年什么时候复活节还为时过早。 然后,您可以预定该日期的假期,并在全家人出席复活节晚餐时出门在外!
Last week, Excel MVP Jerry Latham showed us how to calculate distance in Excel, based on starting and ending points.
上周,Excel MVP Jerry Latham向我们展示了如何基于起点和终点来计算Excel中的距离 。
Today, Jerry explains how you can calculate Easter dates in Excel, using a worksheet formula or Excel User Defined Function (UDF).
今天,Jerry解释了如何使用工作表公式或Excel用户定义函数(UDF) 在Excel中计算复活节日期 。
复活节公式 (Easter Formulas)
First, Jerry gives a few examples of Excel worksheet formulas for Easter dates, where the year is entered in cell A1. This formula, by Norbert Hetterich, works if the regional settings have a day/month/year date format.
首先,Jerry给出了复活节日期的Excel工作表公式的一些示例,其中在单元格A1中输入了年份。 如果区域设置具有日/月/年日期格式,则此公式由Norbert Hetterich编写。
=FLOOR(DAY(MINUTE(A1/38)/2+56)&"/5/"&A1,7)-34
= FLOOR(DAY(MINUTE(A1 / 38)/ 2 + 56)&“ / 5 /”&A1,7)-34
And here's another Easter formula, by Thomas Jansen:
这是Thomas Jansen撰写的另一个复活节公式:
=DOLLAR(("4/"&A1)/7+MOD(19*MOD(A1,19)-7,30)*14%,)*7-6
= DOLLAR((“” 4 /“&A1)/ 7 + MOD(19 * MOD(A1,19)-7,30)* 14%,)* 7-6
However, the worksheet formulas can't be used reliably to determine dates of Easter after 2203, and the Hetterich formula fails for 2079.
但是,无法可靠地使用工作表公式确定2203年以后的复活节日期,而海特里希公式在2079年失败。
Easter用户定义函数 (Easter User Defined Functions)
If you're working with a limited range of years, one of the worksheet functions might be all that you need. However, for accuracy in a wider range of years, you can use an Excel UDF instead.
如果您使用的年份范围有限,则可能只需要工作表功能之一。 但是,为了在更广泛的范围内保持准确性,可以改用Excel UDF。
Jerry's article includes 4 Excel UDFs for calculating Easter dates in Excel, and he has tested all the UDFs for speed and accuracy.
Jerry的文章包括4个Excel UDF,用于在Excel中计算复活节日期 ,并且他已经测试了所有UDF的速度和准确性。
To use the UDFs, copy the code to your workbook, then type the function name in a worksheet formula, e.g.
要使用UDF,请将代码复制到工作簿中,然后在工作表公式中键入函数名称,例如
=CalculateEaster(A1)
= CalculateEaster(A1)
下载复活节日期工作簿 (Download the Easter Date Workbook)
Visit the Excel Easter Date Calculation page on the Contextures website, where you can see the Easter formulas and UDFs, and copy them to your own workbook. Or, download Jerry's sample file, and work with the code and formulas there.
访问Contextures网站上的Excel Easter Date Calculation页面,您可以在其中查看Easter公式和UDF,并将其复制到自己的工作簿中。 或者,下载Jerry的示例文件,然后在其中使用代码和公式。
If you have questions or comments, please let Jerry know. You can post a comment below, or send him an email at [email protected] ________________
如果您有任何疑问或意见,请告诉Jerry。 您可以在下面发表评论,或通过[电子邮件保护]
翻译自: https://contexturesblog.com/archives/2011/09/26/excel-easter-date-calculations/
c语言计算复活节计算