65.9K
CodeProject is changing. Read more.
Home

Computing Easter Date - VB Function

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.03/5 (12 votes)

Apr 8, 2004

CPOL
viewsIcon

63552

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:

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