Search code examples
c#.netcronquartz-schedulerquartz.net-2.0

How to specify multiple nth days in Quartz?


I have a requirement to execute a task every 3 months on the 3rd Tuesday and 3rd Thursday of the month.

The CRON expression that I have come up with is:

0 15 0 ? 3/3 3#3,5#3 *

However when I try to parse this using Quartz 2.2.1:

var cron = new Quartz.CronExpression("0 15 0 ? 3/3 3#3,5#3 *");
cron.GetNextValidTimeAfter(DateTimeOffset.Now).Dump();

I get:

FormatException: Support for specifying multiple "nth" days is not implemented.

Any ideas on how to get this implemented without having to resort to two separate CRON jobs, e.g:

// Tuesday
0 15 0 ? 3/3 3#3 *

// Thursday
0 15 0 ? 3/3 5#3 *

Solution

  • As of today, this feature is not supported and as you have mentioned the best way to achieve what you want is by specifying two separate CRON jobs.