I try to call something every 3 months (quarterly) in Quartz.NET (using both stable and latest version 2, which is a beta version with the same results).
I create a cron trigger 0 30 8 3 */3 ? *, which is called every 3 months at 8:30 in the third month of the month when it occurs.
So technically, from September 2, today I expect this to call tomorrow. However, next time it will be shown next month. Why is this so?
Updated: In accordance with the answers I received, I created the following method - it may be useful for someone:
public static string CalculateMonthsWithInterval(int startMonth, int interval)
{
var months = new List<string>();
var monthNames = new [] {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
var monthSelector = startMonth % interval;
for (var i = 0; i < 12; i++)
{
if (i % interval == monthSelector)
{
months.Add(monthNames[i]);
}
}
return string.Join(",", months.ToArray());
}
Ps: I have not used indexes for several months because for some reason it did not work with my quartz (v2 BETA). It is also easier to read at the database level.
- 3 startDate:
var cronMonths = CronUtils.CalculateMonthsWithInterval((startDate.Month - 1), 3);