Cron expression on 1st business day on or after 15th of every month

I am trying to find a CRON expression that runs on 1st business day on or after 15th of the every month.

The expression: 0 0 0 15W * ? * is almost doing the job but it doesn’t work if the 15th day is falling on Saturday because it will consider the nearest weekday as Friday i.e. 14th. Any idea on how to fix it?

Hi @haritha_hari

Try this Cron expression:

0 0 0 ? * MON-FRI#1

Explanation:

  • 0 0 0: Specifies the time as midnight (00:00:00).
  • ?: Allows the day-of-month field to be any value.
  • *: Allows any valid value for the month field.
  • MON-FRI#1: Specifies the condition for the day of the week. MON-FRI indicates that the day should be a weekday (Monday to Friday), and #1 specifies the first occurrence of that weekday after the condition.

This expression will ensure that the task runs on the 1st business day on or after the 15th of every month, even if the 15th falls on a weekend.

Hope it helps!!
Regards