Computing Easter Date - VB Function






1.03/5 (12 votes)
VB Function to Comput Easter Date
Introduction
Wen i start to work with the calendar control i felt the necessity to obtain the Ester Date to compute the other two moving Holy-Days, The Ash Wednesday -47 Days and corpus christy + 60 Days in order to mark that days in the calendar as holy-Days.
So i surf the net to study the problem and i found these URLs:
- http://aa.usno.navy.mil/faq/docs/easter.html
- http://www.erlandsendata.no/english/functions/date/easter.php
With that it was easy to convert that to this function that receiving the year returns the Easter date:
In VB:
Function F_easter_date(Year_of_easter as integer)
Dim y as integer = Year_of_easter
Dim d As Integer = (((255 - 11 * (y Mod 19)) - 21) Mod 30) + 21
Dim easter_date = New DateTime(y, 3, 1)
easter_date = easter_date.AddDays(+ d + (d > 48) + 6 - ((y + y \ 4 + d + (d > 48) + 1) Mod 7))
return(easter_date)
End function
Then:
Sub ex() Dim Date_AshWednesday as DateTime = F_easter_date("str_Year").AddDays(-47) Dim Date_CorpusChristy as DateTime = F_easter_date("str_Year").AddDays(60) End Sub
In Excel:
=FLOOR(DAY(MINUTE(A1/38)/2+56)&"/5/"&A1;7)-34