Shalom, I am creating some pastoral care software for synagogues. One feature is the tracking of anniversary dates of life events - simchas, yahrzeits, etc. For this, I allow the user to set a reminder in advance of that date - 'Remind me x days before the anniversary date'. So, I may need to know the number of days in the previous month (or months). Eg. If the special event occurs 2nd Tishrei, and the reminder is 7 days before, I need to know first what month that would be (inc. accommodations for leap year Adar II) and how many days in the previous month.

Given that the number of days in several Hebrew months varies and with leap years, so does the number of months, I'm looking for a reliable mathematical way to programmatically calculate the number of days in the preceding month of that given Hebrew year.

Any help would be much appreciated.

  • 1
    This is a backwards way to do it, but couldn't you just convert the Jewish date to the secular one and program to remind "X days before on the secular calendar" which won't depend on the Jewish months.
    – rosends
    Aug 16, 2019 at 16:05
  • Yes, and I'm leaning that way. But If there is a mathematical formula, it seems 'tighter'. I can't find out though. Aug 16, 2019 at 16:09
  • 1
    Thanks for the suggestions. I think I'll use Gregorian date libraries as follows: - convert anniversary to Greg. Subtract x days. Convert that date back to Hebrew. Should be good. Aug 16, 2019 at 17:04
  • 1
    Possible duplicate of Easy method to convert Jewish dates to Gregorian dates?
    – DonielF
    Aug 16, 2019 at 19:05
  • 1
    You might not need to reinvent the wheel. Take a look at hebcal.com, they have an API, maybe you can use that. Aug 16, 2019 at 19:26

1 Answer 1


To somewhat condense some of the previous comments - As long as the anniversary as well as the # of days behind don't cross into either Cheshvan or Kislev, the month lengths are known and constant. Even Adar I and II have fixed lengths, and leap years occur during specific points in the 19 year cycle. As for Cheshvan and Kislev, you would have to know the starting dates of Rosh Hashanna for both the current and following years to determine the year length, and that will, in turn dictate the length of Cheshvan and Kislev.

That's not so simple as Rosh Hashannah's date starts with knowing the molad and then, there are 4 rules that could postpone that date by 1 or two days. Or, you can create a "lookup table" by entering the year and the "type of year" or year length, and use that. You can find that info online in various places.

Years ago, I wrote a Visual Basic program with Excel to calculate all this. If you're interested, inform me. I will warn that I won't have time to hunt for it for several weeks, though.

Not the answer you're looking for? Browse other questions tagged .