This error occurs usually if you use the macro function EncodeMuslimDate, with a Muslim day number which does not correspond to the actual number of days in the specified month for the specified year.
This usually means you specified the 30th of a month having only 29 days on the specified year, as in the top line of the example below.
nLastDayof1440ah = EncodeMuslimDate(1440,12,30) // BAD !!!
nLastDayof1440ah = EncodeMuslimDate(1441,1,1) - 1 // good
To calculate the last day of a Muslim month, calculate the date of the first day of the next month, and then go back one day, as shown in the bottom line of the example above.
Topic 148900, last updated on 13-Apr-2020