# How can I calculate the number of days in a Hebrew month in a given year [closed]

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.

• 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. Aug 16 '19 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 '19 at 16:09
• 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 '19 at 17:04
• Possible duplicate of Easy method to convert Jewish dates to Gregorian dates? Aug 16 '19 at 19:05
• 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 '19 at 19:26