Click here to Skip to main content
15,918,808 members
Articles / Programming Languages / Visual Basic
Tip/Trick

Computing Easter Date - VB Function

Rate me:
Please Sign up or sign in to vote.
1.03/5 (13 votes)
12 Mar 2013CPOL 63.2K   19   5
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:

VB.NET
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:

VB.NET
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:

VB.NET
=FLOOR(DAY(MINUTE(A1/38)/2+56)&"/5/"&A1;7)-34

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Portugal Portugal
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
PraiseCode Pin
Member 1191867623-Oct-18 8:47
Member 1191867623-Oct-18 8:47 
GeneralMy vote of 5 Pin
Global Analyser3-Nov-10 9:28
Global Analyser3-Nov-10 9:28 
Generallittle bug Pin
iakivm26-Oct-09 5:13
iakivm26-Oct-09 5:13 
Question?????? Pin
Kandjar8-Apr-04 1:47
Kandjar8-Apr-04 1:47 
?????? Confused | :confused: ?????? Confused | :confused: ??????

D'Oh! | :doh:
AnswerRe: ?????? Pin
Jose Xavier15-Apr-04 5:46
Jose Xavier15-Apr-04 5:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.