https://en.wikibooks.org/wiki/Mathematics_of_the_Jewish_Calendar/Gauss'_Formula_for_the_Date_of_Pesach

Sorry for being late in answering, but since I was getting inconsistent results I took my time to check this and that.

At first I thought I had problems with leap-year, but then I saw that inconsistencies spread too far.

Then I also found that sometimes m would return a day > 31 (for instance 64); so I added some code, below.

Any suggestions? Thanks.

Using the code below for a range of years 2015 - 2037, I get the following wrong results:

2015 Apr 2 instead of 3

2016 Apr 21 instead of 22

2020 Apr 7 instead of 8

2022 Apr 16 instead of 15

2023 Apr 2 instead of 5

2024 Apr 25 instead of 22

2029 March 28 instead of 30

2030 Apr 18 instead of 17

2031 Apr 6 instead of 7

2032 Apr 24 instead of 26

2033 Apr 14 instead of 13

2035 Apr 22 instead of 23

2016 Apr 10 instead of 11

[code]dim selectedYear as Integer = 2019//val(datePopup(2).Text)

dim y as Integer = 3761 + selectedYear

dim a as Integer = ((12 * y) + 17) MOD 19

dim b as Integer = y MOD 4

dim n as Double = 32 + (4343/98496) + (1 + (272953/492480)) * a + (b/4) - ((313 / 98496) * y)

//alternative calculation found on internet: it returns the same n value as above

//dim n as double = (3156215 / 98496) + ((765433 / 492480) * ((12*y + 17) MOD 19)) + ((y mod 4) / 4) - ((313 / 98496) * y)

dim m as Integer = n//sometimes m returns a day >= 31 (for instance 68), that pushes the month to May.

'if checkLeapYear(selectedYear) then//sometimes, here, it returns the right day (m), sometimes not

'm = m + 1

'end if

dim s as string = format(44, “#.#”)

dim decSeparator as string = right(s,1)

dim o as String = Format(n, “##.####”)

dim splitter() as String = Split(o, decSeparator)

dim decim as Integer = val(splitter(1))

dim c as Integer = ((3* y) + (5*b) + m + 5) MOD 7

if c = 2 or c = 4 or c = 6 then

m = m + 1

elseif c = 1 and a > 6 and decim >= 1367/2160 then//not sure if the original "c = 1, a > 6 and m… correspond to c = 1 AND a > 6 etc

m = m+2

elseif c = 0 and a > 11 and decim >= 23269/25920 then//same as above: c = 0, a > 11…

m = m+1

end if

'if checkLeapYear(selectedYear) then//sometimes, here, it returns the right day (m), sometimes not

'm = m + 1

'end if

if m >= 31 then//for day >= 31, in order to set the month (may) back to April

m = m - 31

end if

//adjust the year from julian to gregorian. To be added to d.day

// Below, adjust also the day from julian to greg (10 days)

dim JulToGreg as Integer = val(left(str(selectedYear), 2))//keep the first 2 digits (20 out of 2019)

JulToGreg = JulToGreg - 2 - (JulToGreg\4)//wrong using / instead of \

dim d as new date

d.Year = selectedYear

d.Month = 3

d.Day = m

d.Day = d.Day + julToGreg

if selectedYear > 1582 then//adjust the day from julian to gregorian

d.day = d.day + 10

end if

d.TotalSeconds = d.TotalSeconds

Label1.text = d.LongDate

[/code]