# I am looking for an algorithm to calculate Molad Tishrei for any given year

I am using MS Excel together with VBA (Visual Basic for applications) to write macros to calculate Molad Tishrei.

I have located information in various web sites that explain how to calculate Molad Toshrei for 1 year if I know the Molad of the previous year. However, I cannot use a fixed calculation for determining the Molad of a random year, since I don't know how many leap years occurred since that random year, and the result comes out incorrectly.

I found some web articles that explain the overall concepts, but I need a step by step algorithm or math formula that works. I.e. - if I know when Molad Toshrei for 5774 was, and I want to find out Molad Tishrei for 5790, how do I do that?

Ideally, if someone has written VB code or done this in Excel, that would be great. However, even if I have a "simplified" stepwise English-explained algorithm, that would work as well.

You don't have to answer with code, of course. A link would be fine. If you have tested the code yourself and verified that it works, even better!

Here's a detailed explanation, with pseudocode-like notation. http://individual.utoronto.ca/kalendis/hebrew/molad.htm#calc.

The following is my own summary:

``````MonthlyMoladDifference = 29 days + 12 hours + (44 + 1/18) minutes.

for(year=5775; year<currentYear; year++) {
IsLeapYear = [0, 3, 6, 8, 11, 14, 17] contains (year % 19)
if(isLeapYear) then
else
}
// NewMolad now contains the molad for Tishrei of the current year.

``````
• Thanks. I translated the loop idea into VBA and it works great!
– DanF
Commented Sep 14, 2014 at 15:21

Copying Ypnypn's pseudocode and adjusting it so it can check all years and so it doesn't require a loop:

``````MonthlyMoladDifference := 36:44:03.33...

Molad := 29:11:20 //comment: tohu (year 1)

input Year
Cycles = Year/19 //comment: integer division
Remainder = Year modulo 19 //comment: 0..18